Core/Chat: Allow incorrect spell/skill language assignments to mirror client behavior

Port From (https://github.com/TrinityCore/TrinityCore/commit/14098b28b39bc9d1ea17d18a7ecd3dd610f29cdc)
This commit is contained in:
hondacrx
2021-05-03 22:15:02 -04:00
parent 89633000d1
commit cbb22d291e
10 changed files with 89 additions and 132 deletions
+4 -14
View File
@@ -106,27 +106,17 @@ namespace Game
}
// prevent talking at unknown language (cheating)
LanguageDesc langDesc = Global.LanguageMgr.GetLanguageDescById(lang);
if (langDesc == null)
var languageData = Global.LanguageMgr.GetLanguageDescById(lang);
if (languageData.Empty())
{
SendNotification(CypherStrings.UnknownLanguage);
return;
}
if (langDesc.SkillId != 0 && !sender.HasSkill((SkillType)langDesc.SkillId))
if (!languageData.Any(langDesc => langDesc.SkillId == 0 || sender.HasSkill((SkillType)langDesc.SkillId)))
{
// also check SPELL_AURA_COMPREHEND_LANGUAGE (client offers option to speak in that language)
var langAuras = sender.GetAuraEffectsByType(AuraType.ComprehendLanguage);
bool foundAura = false;
foreach (var eff in langAuras)
{
if (eff.GetMiscValue() == (int)lang)
{
foundAura = true;
break;
}
}
if (!foundAura)
if (!sender.HasAuraTypeWithMiscvalue(AuraType.ComprehendLanguage, (int)lang))
{
SendNotification(CypherStrings.NotLearnedLanguage);
return;