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

#include <ChatLink.h>

Public Member Functions

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

Protected Attributes

uint32 _guid
 
AchievementEntry const_achievement
 
uint32 _data [8]
 

Constructor & Destructor Documentation

AchievementChatLink::AchievementChatLink ( )
inline
107  : ChatLink(), _guid(0), _achievement(NULL)
108  {
109  memset(_data, 0, sizeof(_data));
110  }
arena_t NULL
Definition: jemalloc_internal.h:624

Member Function Documentation

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

Implements ChatLink.

371 {
373  return false;
374  // Read achievemnt Id
375  uint32 achievementId = 0;
376  if (!ReadUInt32(iss, achievementId))
377  {
378  TC_LOG_TRACE("chat.system", "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading achievement entry", iss.str().c_str());
379  return false;
380  }
381  // Validate achievement
382  _achievement = sAchievementMgr->GetAchievement(achievementId);
383  if (!_achievement)
384  {
385  TC_LOG_TRACE("chat.system", "ChatHandler::isValidChatMessage('%s'): got invalid achivement id %u in |achievement command", iss.str().c_str(), achievementId);
386  return false;
387  }
388  // Check delimiter
389  if (!CheckDelimiter(iss, DELIMITER, "achievement"))
390  return false;
391  // Read HEX
392  if (!ReadHex(iss, _guid, 0))
393  {
394  TC_LOG_TRACE("chat.system", "ChatHandler::isValidChatMessage('%s'): invalid hexadecimal number while reading char's guid", iss.str().c_str());
395  return false;
396  }
397  // Skip progress
398  const uint8 propsCount = 8;
399  for (uint8 index = 0; index < propsCount; ++index)
400  {
401  if (!CheckDelimiter(iss, DELIMITER, "achievement"))
402  return false;
403 
404  if (!ReadUInt32(iss, _data[index]))
405  {
406  TC_LOG_TRACE("chat.system", "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading achievement property (%u)", iss.str().c_str(), index);
407  return false;
408  }
409  }
410  return true;
411 }
Definition: SharedDefines.h:4323
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
uint32_t uint32
Definition: Define.h:150
uint8_t uint8
Definition: Define.h:152
#define sAchievementMgr
Definition: AchievementMgr.h:501

+ Here is the call graph for this function:

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

Implements ChatLink.

414 {
415  ChatLink::ValidateName(buffer, context);
416 
417  for (uint8 locale = LOCALE_enUS; locale < TOTAL_LOCALES; ++locale)
418  {
419  if (locale == LOCALE_none)
420  continue;
421 
422  if (strcmp(_achievement->Title->Str[locale], buffer) == 0)
423  return true;
424  }
425 
426  TC_LOG_TRACE("chat.system", "ChatHandler::isValidChatMessage('%s'): linked achievement (id: %u) name wasn't found in any localization", context, _achievement->ID);
427  return false;
428 }
Definition: Common.h:126
char const * Str[TOTAL_LOCALES]
Definition: Common.h:148
LocalizedString * Title
Definition: DB2Structure.h:33
uint32 ID
Definition: DB2Structure.h:29
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
Definition: Common.h:117
uint8_t uint8
Definition: Define.h:152
Definition: Common.h:130

+ Here is the call graph for this function:

Member Data Documentation

AchievementEntry const* AchievementChatLink::_achievement
protected
uint32 AchievementChatLink::_data[8]
protected
uint32 AchievementChatLink::_guid
protected

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