TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SpellChatLink Class Reference

#include <ChatLink.h>

Public Member Functions

 SpellChatLink ()
 
virtual bool Initialize (std::istringstream &iss) override
 
virtual bool ValidateName (char *buffer, const char *context) override
 

Protected Attributes

SpellInfo const_spell
 

Constructor & Destructor Documentation

SpellChatLink::SpellChatLink ( )
inline
95 : ChatLink(), _spell(nullptr) { }

Member Function Documentation

bool SpellChatLink::Initialize ( std::istringstream &  iss)
overridevirtual

Implements ChatLink.

Reimplemented in GlyphChatLink, EnchantmentChatLink, TalentChatLink, and TradeChatLink.

305 {
307  return false;
308  // Read spell id
309  uint32 spellId = 0;
310  if (!ReadUInt32(iss, spellId))
311  {
312  TC_LOG_TRACE("chat.system", "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading spell entry", iss.str().c_str());
313  return false;
314  }
315  // Validate spell
316  _spell = sSpellMgr->GetSpellInfo(spellId);
317  if (!_spell)
318  {
319  TC_LOG_TRACE("chat.system", "ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |spell command", iss.str().c_str(), spellId);
320  return false;
321  }
322  return true;
323 }
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
#define sSpellMgr
Definition: SpellMgr.h:756
uint32_t uint32
Definition: Define.h:150
Definition: SharedDefines.h:4321

+ Here is the call graph for this function:

bool SpellChatLink::ValidateName ( char *  buffer,
const char *  context 
)
overridevirtual

Implements ChatLink.

326 {
327  ChatLink::ValidateName(buffer, context);
328 
329  // spells with that flag have a prefix of "$PROFESSION: "
331  {
332  SkillLineAbilityMapBounds bounds = sSpellMgr->GetSkillLineAbilityMapBounds(_spell->Id);
333  if (bounds.first == bounds.second)
334  {
335  TC_LOG_TRACE("chat.system", "ChatHandler::isValidChatMessage('%s'): skill line not found for spell %u", context, _spell->Id);
336  return false;
337  }
338  SkillLineAbilityEntry const* skillInfo = bounds.first->second;
339  if (!skillInfo)
340  {
341  TC_LOG_TRACE("chat.system", "ChatHandler::isValidChatMessage('%s'): skill line ability not found for spell %u", context, _spell->Id);
342  return false;
343  }
344  SkillLineEntry const* skillLine = sSkillLineStore.LookupEntry(skillInfo->SkillLine);
345  if (!skillLine)
346  {
347  TC_LOG_TRACE("chat.system", "ChatHandler::isValidChatMessage('%s'): skill line not found for skill %u", context, skillInfo->SkillLine);
348  return false;
349  }
350 
351  uint32 skillLineNameLength = strlen(skillLine->DisplayName_lang);
352  if (skillLineNameLength > 0 && strncmp(skillLine->DisplayName_lang, buffer, skillLineNameLength) == 0)
353  {
354  // found the prefix, remove it to perform spellname validation below
355  // -2 = strlen(": ")
356  uint32 spellNameLength = strlen(buffer) - skillLineNameLength - 2;
357  memmove(buffer, buffer + skillLineNameLength + 2, spellNameLength + 1);
358  }
359  }
360 
361  if (*_spell->SpellName && strcmp(_spell->SpellName, buffer) == 0)
362  return true;
363 
364  TC_LOG_TRACE("chat.system", "ChatHandler::isValidChatMessage('%s'): linked spell (id: %u) name wasn't found in any localization", context, _spell->Id);
365  return false;
366 }
Definition: DBCStructure.h:952
uint32 Id
Definition: SpellInfo.h:329
DBCStorage< SkillLineEntry > sSkillLineStore(SkillLinefmt)
Definition: SharedDefines.h:361
std::pair< SkillLineAbilityMap::const_iterator, SkillLineAbilityMap::const_iterator > SkillLineAbilityMapBounds
Definition: SpellMgr.h:549
uint32 SkillLine
Definition: DBCStructure.h:968
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
#define sSpellMgr
Definition: SpellMgr.h:756
char * SpellName
Definition: SpellInfo.h:392
uint32_t uint32
Definition: Define.h:150
char * DisplayName_lang
Definition: DBCStructure.h:956
Definition: DBCStructure.h:965

+ Here is the call graph for this function:

Member Data Documentation

SpellInfo const* SpellChatLink::_spell
protected

The documentation for this class was generated from the following files: