Core/Chat: Fix validation of tradeskill recipes that belong to multiple skill lines

This commit is contained in:
Treeston
2018-09-17 21:29:07 +02:00
parent 152f3fc3e3
commit 2dc174029c

View File

@@ -219,22 +219,27 @@ struct LinkValidator<LinkTags::enchant>
{
static bool IsTextValid(SpellInfo const* info, char const* pos, size_t len)
{
if (LinkValidator<LinkTags::spell>::IsTextValid(info, pos, len))
return true;
SkillLineAbilityMapBounds bounds = sSpellMgr->GetSkillLineAbilityMapBounds(info->Id);
if (bounds.first == bounds.second)
return LinkValidator<LinkTags::spell>::IsTextValid(info, pos, len);
SkillLineEntry const* skill = sSkillLineStore.LookupEntry(bounds.first->second->skillId);
if (!skill)
return false;
for (uint8 i = 0; i < TOTAL_LOCALES; ++i)
for (auto pair = bounds.first; pair != bounds.second; ++pair)
{
char const* skillName = skill->name[i];
size_t skillLen = strlen(skillName);
if (len > skillLen + 2 && // or of form [Skill Name: Spell Name]
!strncmp(pos, skillName, skillLen) && !strncmp(pos + skillLen, ": ", 2) &&
equal_with_len(info->SpellName[i], pos + (skillLen + 2), len - (skillLen + 2)))
return true;
SkillLineEntry const* skill = sSkillLineStore.LookupEntry(pair->second->skillId);
if (!skill)
return false;
for (uint8 i = 0; i < TOTAL_LOCALES; ++i)
{
char const* skillName = skill->name[i];
size_t skillLen = strlen(skillName);
if (len > skillLen + 2 && // or of form [Skill Name: Spell Name]
!strncmp(pos, skillName, skillLen) && !strncmp(pos + skillLen, ": ", 2) &&
equal_with_len(info->SpellName[i], pos + (skillLen + 2), len - (skillLen + 2)))
return true;
}
}
return false;
}