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

#include <ChatLink.h>

Public Member Functions

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

Protected Attributes

Quest const_quest
 
int32 _questLevel
 

Constructor & Destructor Documentation

QuestChatLink::QuestChatLink ( )
inline
82 : ChatLink(), _quest(nullptr), _questLevel(0) { }

Member Function Documentation

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

Implements ChatLink.

251 {
252  // Read quest id
253  uint32 questId = 0;
254  if (!ReadUInt32(iss, questId))
255  {
256  TC_LOG_TRACE("chat.system", "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading quest entry", iss.str().c_str());
257  return false;
258  }
259  // Validate quest
260  _quest = sObjectMgr->GetQuestTemplate(questId);
261  if (!_quest)
262  {
263  TC_LOG_TRACE("chat.system", "ChatHandler::isValidChatMessage('%s'): quest template %u not found", iss.str().c_str(), questId);
264  return false;
265  }
266  // Check delimiter
267  if (!CheckDelimiter(iss, DELIMITER, "quest"))
268  return false;
269  // Read quest level
270  if (!ReadInt32(iss, _questLevel))
271  {
272  TC_LOG_TRACE("chat.system", "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading quest level", iss.str().c_str());
273  return false;
274  }
275  // Validate quest level
277  {
278  TC_LOG_TRACE("chat.system", "ChatHandler::isValidChatMessage('%s'): quest level %d is too big", iss.str().c_str(), _questLevel);
279  return false;
280  }
281  return true;
282 }
Definition: DBCEnums.h:54
#define sObjectMgr
Definition: ObjectMgr.h:1567
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
uint32_t uint32
Definition: Define.h:150

+ Here is the call graph for this function:

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

Implements ChatLink.

285 {
286  ChatLink::ValidateName(buffer, context);
287 
288  bool res = (_quest->GetLogTitle() == buffer);
289  if (!res)
290  if (QuestTemplateLocale const* ql = sObjectMgr->GetQuestLocale(_quest->GetQuestId()))
291  for (uint8 i = 0; i < ql->LogTitle.size(); i++)
292  if (ql->LogTitle[i] == buffer)
293  {
294  res = true;
295  break;
296  }
297  if (!res)
298  TC_LOG_TRACE("chat.system", "ChatHandler::isValidChatMessage('%s'): linked quest (id: %u) title wasn't found in any localization", context, _quest->GetQuestId());
299  return res;
300 }
Definition: QuestDef.h:239
#define sObjectMgr
Definition: ObjectMgr.h:1567
uint32 GetQuestId() const
Definition: QuestDef.h:304
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
uint8_t uint8
Definition: Define.h:152
std::string const & GetLogTitle() const
Definition: QuestDef.h:334

+ Here is the call graph for this function:

Member Data Documentation

Quest const* QuestChatLink::_quest
protected
int32 QuestChatLink::_questLevel
protected

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