39 iss >> std::dec >> res;
40 return !iss.fail() && !iss.eof();
45 iss >> std::dec >> res;
46 return !iss.fail() && !iss.eof();
49inline std::string
ReadSkip(std::istringstream& iss,
char term)
53 while (c != term && c !=
'\0')
62inline bool CheckDelimiter(std::istringstream& iss,
char delimiter,
const char* context)
67 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): invalid %s link structure ('%c' expected, '%c' found)", iss.str().c_str(), context, delimiter, c);
76 std::istringstream::pos_type pos = iss.tellg();
77 iss >> std::hex >> res;
79 if (length &&
uint32(iss.tellg() - pos) != length)
81 return !iss.fail() && !iss.eof();
101 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading item entry", iss.str().c_str());
108 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): got invalid itemEntry %u in |item command", iss.str().c_str(), itemEntry);
118 const uint8 propsCount = 8;
119 const uint8 randomPropertyPosition = 5;
120 for (
uint8 index = 0; index < propsCount; ++index)
128 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading item property (%u)", iss.str().c_str(), index);
131 if (
id && (index == randomPropertyPosition))
139 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): got invalid item property id %u in |item command", iss.str().c_str(),
id);
148 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): got invalid item suffix id %u in |item command", iss.str().c_str(), -
id);
160 std::stringstream ss;
161 if (locale == NULL || index >= locale->
Name.size())
164 ss << locale->
Name[index];
166 ss <<
' ' << suffixStrings[index];
182 if (
FormatName(index, il, suffixStrings) == buffer)
190 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): linked item (id: %u) name wasn't found in any localization", context,
_item->ItemId);
202 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading quest entry", iss.str().c_str());
209 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): quest template %u not found", iss.str().c_str(), questId);
218 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading quest level", iss.str().c_str());
224 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): quest level %d is too big", iss.str().c_str(),
_questLevel);
234 bool res = (
_quest->GetTitle() == buffer);
237 for (
uint8 i = 0; i < ql->Title.size(); i++)
238 if (ql->Title[i] == buffer)
244 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): linked quest (id: %u) title wasn't found in any localization", context,
_quest->GetQuestId());
258 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading spell entry", iss.str().c_str());
265 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |spell command", iss.str().c_str(), spellId);
279 if (bounds.first == bounds.second)
281 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): skill line not found for spell %u", context,
_spell->Id);
287 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): skill line ability not found for spell %u", context,
_spell->Id);
293 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): skill line not found for skill %u", context, skillInfo->
skillId);
297 uint32 skillLineNameLength = strlen(skillLine->
name);
298 if (skillLineNameLength > 0 && strncmp(skillLine->
name, buffer, skillLineNameLength) == 0)
302 uint32 spellNameLength = strlen(buffer) - skillLineNameLength - 2;
303 memcpy(buffer, buffer + skillLineNameLength + 2, spellNameLength + 1);
307 if (*
_spell->SpellName && strcmp(
_spell->SpellName, buffer) == 0)
310 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): linked spell (id: %u) name wasn't found in any localization", context,
_spell->Id);
324 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading achievement entry", iss.str().c_str());
331 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): got invalid achivement id %u in |achievement command", iss.str().c_str(), achievementId);
340 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): invalid hexadecimal number while reading char's guid", iss.str().c_str());
344 const uint8 propsCount = 8;
345 for (
uint8 index = 0; index < propsCount; ++index)
352 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading achievement property (%u)", iss.str().c_str(), index);
366 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): linked achievement (id: %u) name wasn't found in any localization", context,
_achievement->ID);
380 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading achievement entry", iss.str().c_str());
387 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |trade command", iss.str().c_str(), spellId);
396 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading minimum talent level", iss.str().c_str());
405 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading maximum talent level", iss.str().c_str());
414 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading achievement's owner guid", iss.str().c_str());
431 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading talent entry", iss.str().c_str());
438 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): got invalid talent id %u in |talent command", iss.str().c_str(),
_talentId);
445 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |trade command", iss.str().c_str(), talentInfo->
SpellId);
454 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading talent rank", iss.str().c_str());
470 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading enchantment spell entry", iss.str().c_str());
477 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |enchant command", iss.str().c_str(), spellId);
492 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading slot id", iss.str().c_str());
502 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading glyph entry", iss.str().c_str());
509 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): got invalid glyph id %u in |glyph command", iss.str().c_str(), glyphId);
516 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |glyph command", iss.str().c_str(),
_glyph->SpellId);
526 for (Links::iterator itr =
_links.begin(); itr !=
_links.end(); ++itr)
533 const char validSequence[6] =
"cHhhr";
534 const char* validSequenceIterator = validSequence;
538 std::istringstream::pos_type startPos = 0;
544 if (validSequence == validSequenceIterator)
548 startPos =
_iss.tellg() - std::istringstream::pos_type(1);
552 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): sequence aborted unexpectedly",
_iss.str().c_str());
557 if (
_iss.peek() ==
'\0')
559 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): pipe followed by '\\0'",
_iss.str().c_str());
573 if (commandChar == *validSequenceIterator)
575 if (validSequenceIterator == validSequence + 4)
576 validSequenceIterator = validSequence;
578 ++validSequenceIterator;
582 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): invalid sequence, expected '%c' but got '%c'",
_iss.str().c_str(), *validSequenceIterator, commandChar);
586 else if (validSequence != validSequenceIterator)
589 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): got escaped pipe in sequence",
_iss.str().c_str());
598 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): invalid hexadecimal number while reading color",
_iss.str().c_str());
607 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly",
_iss.str().c_str());
611 if (strcmp(buffer,
"item") == 0)
613 else if (strcmp(buffer,
"quest") == 0)
615 else if (strcmp(buffer,
"trade") == 0)
617 else if (strcmp(buffer,
"talent") == 0)
619 else if (strcmp(buffer,
"spell") == 0)
621 else if (strcmp(buffer,
"enchant") == 0)
623 else if (strcmp(buffer,
"achievement") == 0)
625 else if (strcmp(buffer,
"glyph") == 0)
629 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): user sent unsupported link type '%s'",
_iss.str().c_str(), buffer);
639 if (*validSequenceIterator ==
'h')
642 if (
_iss.get() !=
'[')
644 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): link caption doesn't start with '['",
_iss.str().c_str());
647 _iss.getline(buffer, 256,
']');
650 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly",
_iss.str().c_str());
668 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): got invalid command |%c",
_iss.str().c_str(), commandChar);
674 if (validSequence != validSequenceIterator)
676 SF_LOG_TRACE(
"chat.system",
"ChatHandler::isValidChatMessage('%s'): EOF in active sequence",
_iss.str().c_str());
std::string ReadSkip(std::istringstream &iss, char term)
bool CheckDelimiter(std::istringstream &iss, char delimiter, const char *context)
bool ReadInt32(std::istringstream &iss, int32 &res)
bool ReadHex(std::istringstream &iss, uint32 &res, uint32 length)
bool ReadUInt32(std::istringstream &iss, uint32 &res)
const uint8 TOTAL_LOCALES
DBCStorage< ItemRandomSuffixEntry > sItemRandomSuffixStore(ItemRandomSuffixfmt)
DBCStorage< ItemRandomPropertiesEntry > sItemRandomPropertiesStore(ItemRandomPropertiesfmt)
DBCStorage< SkillLineEntry > sSkillLineStore(SkillLinefmt)
DBCStorage< TalentEntry > sTalentStore(TalentEntryfmt)
DBCStorage< GlyphPropertiesEntry > sGlyphPropertiesStore(GlyphPropertiesfmt)
#define SF_LOG_TRACE(filterType__,...)
const uint32 ItemQualityColors[MAX_ITEM_QUALITY]
@ CHAT_LINK_COLOR_ACHIEVEMENT
@ CHAT_LINK_COLOR_ENCHANT
std::pair< SkillLineAbilityMap::const_iterator, SkillLineAbilityMap::const_iterator > SkillLineAbilityMapBounds
AchievementEntry const * _achievement
virtual bool Initialize(std::istringstream &iss)
virtual bool ValidateName(char *buffer, const char *context)
void SetBounds(std::istringstream::pos_type startPos, std::istringstream::pos_type endPos)
void SetColor(uint32 color)
virtual bool Initialize(std::istringstream &iss)=0
virtual bool ValidateName(char *buffer, const char *context)=0
virtual bool Initialize(std::istringstream &iss)
GlyphPropertiesEntry const * _glyph
virtual bool Initialize(std::istringstream &iss)
ItemTemplate const * _item
ItemRandomPropertiesEntry const * _property
virtual bool ValidateName(char *buffer, const char *context)
virtual bool Initialize(std::istringstream &iss)
std::string FormatName(uint8 index, ItemLocale const *locale, char *suffixStrings) const
ItemRandomSuffixEntry const * _suffix
virtual bool Initialize(std::istringstream &iss)
virtual bool ValidateName(char *buffer, const char *context)
virtual bool Initialize(std::istringstream &iss)
virtual bool ValidateName(char *buffer, const char *context)
virtual bool Initialize(std::istringstream &iss)
virtual bool Initialize(std::istringstream &iss)