Core/Chat: Fixed possible memory leaks related to chatlink verification
This commit is contained in:
@@ -19,12 +19,6 @@
|
||||
#include "SpellMgr.h"
|
||||
#include "ObjectMgr.h"
|
||||
|
||||
#ifdef TRINITY_DEBUG
|
||||
#define LOG(...) sLog->outDebug(LOG_FILTER_CHATSYS, __VA_ARGS__);
|
||||
#else
|
||||
#define LOG(...)
|
||||
#endif
|
||||
|
||||
// Supported shift-links (client generated and server side)
|
||||
// |color|Hachievement:achievement_id:player_guid:0:0:0:0:0:0:0:0|h[name]|h|r
|
||||
// - client, item icon shift click, not used in server currently
|
||||
@@ -79,7 +73,7 @@ inline bool CheckDelimiter(std::istringstream& iss, char delimiter, const char*
|
||||
char c = iss.peek();
|
||||
if (c != delimiter)
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): invalid %s link structure ('%c' expected, '%c' found)", iss.str().c_str(), context, delimiter, c);
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): invalid %s link structure ('%c' expected, '%c' found)", iss.str().c_str(), context, delimiter, c);
|
||||
return false;
|
||||
}
|
||||
iss.ignore(1);
|
||||
@@ -113,20 +107,20 @@ bool ItemChatLink::Initialize(std::istringstream& iss)
|
||||
uint32 itemEntry = 0;
|
||||
if (!ReadUInt32(iss, itemEntry))
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading item entry", iss.str().c_str());
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading item entry", iss.str().c_str());
|
||||
return false;
|
||||
}
|
||||
// Validate item
|
||||
_item = ObjectMgr::GetItemPrototype(itemEntry);
|
||||
if (!_item)
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): got invalid itemEntry %u in |item command", iss.str().c_str(), itemEntry);
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid itemEntry %u in |item command", iss.str().c_str(), itemEntry);
|
||||
return false;
|
||||
}
|
||||
// Validate item's color
|
||||
if (_color != ItemQualityColors[_item->Quality])
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): linked item has color %u, but user claims %u", iss.str().c_str(), ItemQualityColors[_item->Quality], _color);
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): linked item has color %u, but user claims %u", iss.str().c_str(), ItemQualityColors[_item->Quality], _color);
|
||||
return false;
|
||||
}
|
||||
// Number of various item properties after item entry
|
||||
@@ -140,7 +134,7 @@ bool ItemChatLink::Initialize(std::istringstream& iss)
|
||||
int32 id = 0;
|
||||
if (!ReadInt32(iss, id))
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading item property (%u)", iss.str().c_str(), index);
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading item property (%u)", iss.str().c_str(), index);
|
||||
return false;
|
||||
}
|
||||
if (id && (index == randomPropertyPosition))
|
||||
@@ -151,7 +145,7 @@ bool ItemChatLink::Initialize(std::istringstream& iss)
|
||||
_property = sItemRandomPropertiesStore.LookupEntry(id);
|
||||
if (!_property)
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): got invalid item property id %u in |item command", iss.str().c_str(), id);
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid item property id %u in |item command", iss.str().c_str(), id);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -160,7 +154,7 @@ bool ItemChatLink::Initialize(std::istringstream& iss)
|
||||
_suffix = sItemRandomSuffixStore.LookupEntry(-id);
|
||||
if (!_suffix)
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): got invalid item suffix id %u in |item command", iss.str().c_str(), -id);
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid item suffix id %u in |item command", iss.str().c_str(), -id);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -170,7 +164,7 @@ bool ItemChatLink::Initialize(std::istringstream& iss)
|
||||
return true;
|
||||
}
|
||||
|
||||
inline std::string ItemChatLink::_FormatName(uint8 index, ItemLocale const *locale, char* const* suffixStrings) const
|
||||
inline std::string ItemChatLink::FormatName(uint8 index, ItemLocale const *locale, char* const* suffixStrings) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
if (locale == NULL || index >= locale->Name.size())
|
||||
@@ -188,13 +182,13 @@ bool ItemChatLink::ValidateName(char* buffer, const char* context)
|
||||
|
||||
char* const* suffixStrings = _suffix ? _suffix->nameSuffix : (_property ? _property->nameSuffix : NULL);
|
||||
|
||||
bool res = (_FormatName(LOCALE_enUS, NULL, suffixStrings) == buffer);
|
||||
bool res = (FormatName(LOCALE_enUS, NULL, suffixStrings) == buffer);
|
||||
if (!res)
|
||||
{
|
||||
ItemLocale const *il = sObjectMgr->GetItemLocale(_item->ItemId);
|
||||
for (uint8 index = LOCALE_koKR; index < TOTAL_LOCALES; ++index)
|
||||
{
|
||||
if (_FormatName(index, il, suffixStrings) == buffer)
|
||||
if (FormatName(index, il, suffixStrings) == buffer)
|
||||
{
|
||||
res = true;
|
||||
break;
|
||||
@@ -202,7 +196,7 @@ bool ItemChatLink::ValidateName(char* buffer, const char* context)
|
||||
}
|
||||
}
|
||||
if (!res)
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): linked item (id: %u) name wasn't found in any localization", context, _item->ItemId);
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): linked item (id: %u) name wasn't found in any localization", context, _item->ItemId);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -214,14 +208,14 @@ bool QuestChatLink::Initialize(std::istringstream& iss)
|
||||
uint32 questId = 0;
|
||||
if (!ReadUInt32(iss, questId))
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading quest entry", iss.str().c_str());
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading quest entry", iss.str().c_str());
|
||||
return false;
|
||||
}
|
||||
// Validate quest
|
||||
_quest = sObjectMgr->GetQuestTemplate(questId);
|
||||
if (!_quest)
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): quest template %u not found", iss.str().c_str(), questId);
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): quest template %u not found", iss.str().c_str(), questId);
|
||||
return false;
|
||||
}
|
||||
// Check delimiter
|
||||
@@ -230,13 +224,13 @@ bool QuestChatLink::Initialize(std::istringstream& iss)
|
||||
// Read quest level
|
||||
if (!ReadInt32(iss, _questLevel))
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading quest level", iss.str().c_str());
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading quest level", iss.str().c_str());
|
||||
return false;
|
||||
}
|
||||
// Validate quest level
|
||||
if (_questLevel >= STRONG_MAX_LEVEL)
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): quest level %d is too big", iss.str().c_str(), _questLevel);
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): quest level %d is too big", iss.str().c_str(), _questLevel);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -256,7 +250,7 @@ bool QuestChatLink::ValidateName(char* buffer, const char* context)
|
||||
break;
|
||||
}
|
||||
if (!res)
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): linked quest (id: %u) title wasn't found in any localization", context, _quest->GetQuestId());
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): linked quest (id: %u) title wasn't found in any localization", context, _quest->GetQuestId());
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -270,14 +264,14 @@ bool SpellChatLink::Initialize(std::istringstream& iss)
|
||||
uint32 spellId = 0;
|
||||
if (!ReadUInt32(iss, spellId))
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading spell entry", iss.str().c_str());
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading spell entry", iss.str().c_str());
|
||||
return false;
|
||||
}
|
||||
// Validate spell
|
||||
_spell = sSpellStore.LookupEntry(spellId);
|
||||
if (!_spell)
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |spell command", iss.str().c_str(), spellId);
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |spell command", iss.str().c_str(), spellId);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -293,19 +287,19 @@ bool SpellChatLink::ValidateName(char* buffer, const char* context)
|
||||
SkillLineAbilityMapBounds bounds = sSpellMgr->GetSkillLineAbilityMapBounds(_spell->Id);
|
||||
if (bounds.first == bounds.second)
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): skill line not found for spell %u", context, _spell->Id);
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): skill line not found for spell %u", context, _spell->Id);
|
||||
return false;
|
||||
}
|
||||
SkillLineAbilityEntry const *skillInfo = bounds.first->second;
|
||||
if (!skillInfo)
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): skill line ability not found for spell %u", context, _spell->Id);
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): skill line ability not found for spell %u", context, _spell->Id);
|
||||
return false;
|
||||
}
|
||||
SkillLineEntry const *skillLine = sSkillLineStore.LookupEntry(skillInfo->skillId);
|
||||
if (!skillLine)
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): skill line not found for skill %u", context, skillInfo->skillId);
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): skill line not found for skill %u", context, skillInfo->skillId);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -331,7 +325,7 @@ bool SpellChatLink::ValidateName(char* buffer, const char* context)
|
||||
}
|
||||
|
||||
if (!res)
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): linked spell (id: %u) name wasn't found in any localization", context, _spell->Id);
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): linked spell (id: %u) name wasn't found in any localization", context, _spell->Id);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -345,14 +339,14 @@ bool AchievementChatLink::Initialize(std::istringstream& iss)
|
||||
uint32 achievementId = 0;
|
||||
if (!ReadUInt32(iss, achievementId))
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading achievement entry", iss.str().c_str());
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading achievement entry", iss.str().c_str());
|
||||
return false;
|
||||
}
|
||||
// Validate achievement
|
||||
_achievement = sAchievementStore.LookupEntry(achievementId);
|
||||
if (!_achievement)
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): got invalid achivement id %u in |achievement command", iss.str().c_str(), achievementId);
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid achivement id %u in |achievement command", iss.str().c_str(), achievementId);
|
||||
return false;
|
||||
}
|
||||
// Check delimiter
|
||||
@@ -361,7 +355,7 @@ bool AchievementChatLink::Initialize(std::istringstream& iss)
|
||||
// Read HEX
|
||||
if (!ReadHex(iss, _guid, 0))
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): invalid hexadecimal number while reading char's guid", iss.str().c_str());
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): invalid hexadecimal number while reading char's guid", iss.str().c_str());
|
||||
return false;
|
||||
}
|
||||
// Skip progress
|
||||
@@ -373,7 +367,7 @@ bool AchievementChatLink::Initialize(std::istringstream& iss)
|
||||
|
||||
if (!ReadUInt32(iss, _data[index]))
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading achievement property (%u)", iss.str().c_str(), index);
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading achievement property (%u)", iss.str().c_str(), index);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -393,7 +387,7 @@ bool AchievementChatLink::ValidateName(char* buffer, const char* context)
|
||||
}
|
||||
|
||||
if (!res)
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): linked achievement (id: %u) name wasn't found in any localization", context, _achievement->ID);
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): linked achievement (id: %u) name wasn't found in any localization", context, _achievement->ID);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -407,14 +401,14 @@ bool TradeChatLink::Initialize(std::istringstream& iss)
|
||||
uint32 spellId = 0;
|
||||
if (!ReadUInt32(iss, spellId))
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading achievement entry", iss.str().c_str());
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading achievement entry", iss.str().c_str());
|
||||
return false;
|
||||
}
|
||||
// Validate spell
|
||||
_spell = sSpellStore.LookupEntry(spellId);
|
||||
if (!_spell)
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |trade command", iss.str().c_str(), spellId);
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |trade command", iss.str().c_str(), spellId);
|
||||
return false;
|
||||
}
|
||||
// Check delimiter
|
||||
@@ -423,7 +417,7 @@ bool TradeChatLink::Initialize(std::istringstream& iss)
|
||||
// Minimum talent level
|
||||
if (!ReadInt32(iss, _minSkillLevel))
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading minimum talent level", iss.str().c_str());
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading minimum talent level", iss.str().c_str());
|
||||
return false;
|
||||
}
|
||||
// Check delimiter
|
||||
@@ -432,7 +426,7 @@ bool TradeChatLink::Initialize(std::istringstream& iss)
|
||||
// Maximum talent level
|
||||
if (!ReadInt32(iss, _maxSkillLevel))
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading maximum talent level", iss.str().c_str());
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading maximum talent level", iss.str().c_str());
|
||||
return false;
|
||||
}
|
||||
// Check delimiter
|
||||
@@ -441,7 +435,7 @@ bool TradeChatLink::Initialize(std::istringstream& iss)
|
||||
// Something hexadecimal
|
||||
if (!ReadHex(iss, _guid, 0))
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading achievement's owner guid", iss.str().c_str());
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading achievement's owner guid", iss.str().c_str());
|
||||
return false;
|
||||
}
|
||||
// Skip base64 encoded stuff
|
||||
@@ -458,21 +452,21 @@ bool TalentChatLink::Initialize(std::istringstream& iss)
|
||||
// Read talent entry
|
||||
if (!ReadUInt32(iss, _talentId))
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading talent entry", iss.str().c_str());
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading talent entry", iss.str().c_str());
|
||||
return false;
|
||||
}
|
||||
// Validate talent
|
||||
TalentEntry const *talentInfo = sTalentStore.LookupEntry(_talentId);
|
||||
if (!talentInfo)
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): got invalid talent id %u in |talent command", iss.str().c_str(), _talentId);
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid talent id %u in |talent command", iss.str().c_str(), _talentId);
|
||||
return false;
|
||||
}
|
||||
// Validate talent's spell
|
||||
_spell = sSpellStore.LookupEntry(talentInfo->RankID[0]);
|
||||
if (!_spell)
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |trade command", iss.str().c_str(), talentInfo->RankID[0]);
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |trade command", iss.str().c_str(), talentInfo->RankID[0]);
|
||||
return false;
|
||||
}
|
||||
// Delimiter
|
||||
@@ -481,7 +475,7 @@ bool TalentChatLink::Initialize(std::istringstream& iss)
|
||||
// Rank
|
||||
if (!ReadInt32(iss, _rankId))
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading talent rank", iss.str().c_str());
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading talent rank", iss.str().c_str());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -497,14 +491,14 @@ bool EnchantmentChatLink::Initialize(std::istringstream& iss)
|
||||
uint32 spellId = 0;
|
||||
if (!ReadUInt32(iss, spellId))
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading enchantment spell entry", iss.str().c_str());
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading enchantment spell entry", iss.str().c_str());
|
||||
return false;
|
||||
}
|
||||
// Validate spell
|
||||
_spell = sSpellStore.LookupEntry(spellId);
|
||||
if (!_spell)
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |enchant command", iss.str().c_str(), spellId);
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |enchant command", iss.str().c_str(), spellId);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -519,7 +513,7 @@ bool GlyphChatLink::Initialize(std::istringstream& iss)
|
||||
// Slot
|
||||
if (!ReadUInt32(iss, _slotId))
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading slot id", iss.str().c_str());
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading slot id", iss.str().c_str());
|
||||
return false;
|
||||
}
|
||||
// Check delimiter
|
||||
@@ -529,32 +523,34 @@ bool GlyphChatLink::Initialize(std::istringstream& iss)
|
||||
uint32 glyphId = 0;
|
||||
if (!ReadUInt32(iss, glyphId))
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading glyph entry", iss.str().c_str());
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading glyph entry", iss.str().c_str());
|
||||
return false;
|
||||
}
|
||||
// Validate glyph
|
||||
_glyph = sGlyphPropertiesStore.LookupEntry(glyphId);
|
||||
if (!_glyph)
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): got invalid glyph id %u in |glyph command", iss.str().c_str(), glyphId);
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid glyph id %u in |glyph command", iss.str().c_str(), glyphId);
|
||||
return false;
|
||||
}
|
||||
// Validate glyph's spell
|
||||
_spell = sSpellStore.LookupEntry(_glyph->SpellId);
|
||||
if (!_spell)
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |glyph command", iss.str().c_str(), _glyph->SpellId);
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |glyph command", iss.str().c_str(), _glyph->SpellId);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
LinkExtractor::LinkExtractor(const char* msg) : _iss(msg) { }
|
||||
LinkExtractor::LinkExtractor(const char* msg) : _iss(msg)
|
||||
{
|
||||
}
|
||||
|
||||
LinkExtractor::~LinkExtractor()
|
||||
{
|
||||
for (Links::iterator itr = _links.begin(); itr != _links.end(); ++itr)
|
||||
delete (*itr);
|
||||
delete *itr;
|
||||
_links.clear();
|
||||
}
|
||||
|
||||
@@ -573,24 +569,20 @@ bool LinkExtractor::IsValidMessage()
|
||||
{
|
||||
if (validSequence == validSequenceIterator)
|
||||
{
|
||||
if (link)
|
||||
{
|
||||
_links.push_back(link);
|
||||
link = NULL;
|
||||
}
|
||||
link = NULL;
|
||||
_iss.ignore(255, PIPE_CHAR);
|
||||
startPos = _iss.tellg() - std::istringstream::pos_type(1);
|
||||
}
|
||||
else if (_iss.get() != PIPE_CHAR)
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): sequence aborted unexpectedly", _iss.str().c_str());
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence aborted unexpectedly", _iss.str().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
// pipe has always to be followed by at least one char
|
||||
if (_iss.peek() == '\0')
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): pipe followed by '\\0'", _iss.str().c_str());
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): pipe followed by '\\0'", _iss.str().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -613,14 +605,14 @@ bool LinkExtractor::IsValidMessage()
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): invalid sequence, expected '%c' but got '%c'", _iss.str().c_str(), *validSequenceIterator, commandChar);
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): invalid sequence, expected '%c' but got '%c'", _iss.str().c_str(), *validSequenceIterator, commandChar);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (validSequence != validSequenceIterator)
|
||||
{
|
||||
// no escaped pipes in sequences
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): got escaped pipe in sequence", _iss.str().c_str());
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got escaped pipe in sequence", _iss.str().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -629,7 +621,7 @@ bool LinkExtractor::IsValidMessage()
|
||||
case 'c':
|
||||
if (!ReadHex(_iss, color, 8))
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): invalid hexadecimal number while reading color", _iss.str().c_str());
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): invalid hexadecimal number while reading color", _iss.str().c_str());
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
@@ -638,7 +630,7 @@ bool LinkExtractor::IsValidMessage()
|
||||
_iss.getline(buffer, 256, DELIMITER);
|
||||
if (_iss.eof())
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly", _iss.str().c_str());
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly", _iss.str().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -660,9 +652,10 @@ bool LinkExtractor::IsValidMessage()
|
||||
link = new GlyphChatLink();
|
||||
else
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): user sent unsupported link type '%s'", _iss.str().c_str(), buffer);
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): user sent unsupported link type '%s'", _iss.str().c_str(), buffer);
|
||||
return false;
|
||||
}
|
||||
_links.push_back(link);
|
||||
link->SetColor(color);
|
||||
if (!link->Initialize(_iss))
|
||||
return false;
|
||||
@@ -674,13 +667,13 @@ bool LinkExtractor::IsValidMessage()
|
||||
// links start with '['
|
||||
if (_iss.get() != '[')
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): link caption doesn't start with '['", _iss.str().c_str());
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): link caption doesn't start with '['", _iss.str().c_str());
|
||||
return false;
|
||||
}
|
||||
_iss.getline(buffer, 256, ']');
|
||||
if (_iss.eof())
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly", _iss.str().c_str());
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly", _iss.str().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -698,7 +691,7 @@ bool LinkExtractor::IsValidMessage()
|
||||
// no further payload
|
||||
break;
|
||||
default:
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): got invalid command |%c", _iss.str().c_str(), commandChar);
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid command |%c", _iss.str().c_str(), commandChar);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -706,7 +699,7 @@ bool LinkExtractor::IsValidMessage()
|
||||
// check if every opened sequence was also closed properly
|
||||
if (validSequence != validSequenceIterator)
|
||||
{
|
||||
LOG("ChatHandler::isValidChatMessage('%s'): EOF in active sequence", _iss.str().c_str());
|
||||
sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): EOF in active sequence", _iss.str().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
virtual bool ValidateName(char* buffer, const char* context);
|
||||
|
||||
protected:
|
||||
std::string _FormatName(uint8 index, ItemLocale const *locale, char* const* suffixStrings) const;
|
||||
std::string FormatName(uint8 index, ItemLocale const* locale, char* const* suffixStrings) const;
|
||||
|
||||
ItemPrototype const* _item;
|
||||
int32 _data[8];
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <ace/Auto_Ptr.h>
|
||||
|
||||
#include "Common.h"
|
||||
#include "Item.h"
|
||||
#include "ObjectMgr.h"
|
||||
@@ -28,12 +26,12 @@
|
||||
#include "ScriptMgr.h"
|
||||
#include "ConditionMgr.h"
|
||||
|
||||
void AddItemsSetItem(Player*player,Item *item)
|
||||
void AddItemsSetItem(Player* player,Item* item)
|
||||
{
|
||||
ItemPrototype const *proto = item->GetProto();
|
||||
ItemPrototype const* proto = item->GetProto();
|
||||
uint32 setid = proto->ItemSet;
|
||||
|
||||
ItemSetEntry const *set = sItemSetStore.LookupEntry(setid);
|
||||
ItemSetEntry const* set = sItemSetStore.LookupEntry(setid);
|
||||
|
||||
if (!set)
|
||||
{
|
||||
@@ -44,7 +42,7 @@ void AddItemsSetItem(Player*player,Item *item)
|
||||
if (set->required_skill_id && player->GetSkillValue(set->required_skill_id) < set->required_skill_value)
|
||||
return;
|
||||
|
||||
ItemSetEffect *eff = NULL;
|
||||
ItemSetEffect* eff = NULL;
|
||||
|
||||
for (size_t x = 0; x < player->ItemSetEff.size(); ++x)
|
||||
{
|
||||
@@ -58,11 +56,11 @@ void AddItemsSetItem(Player*player,Item *item)
|
||||
if (!eff)
|
||||
{
|
||||
eff = new ItemSetEffect;
|
||||
memset(eff,0,sizeof(ItemSetEffect));
|
||||
memset(eff, 0, sizeof(ItemSetEffect));
|
||||
eff->setid = setid;
|
||||
|
||||
size_t x = 0;
|
||||
for (; x < player->ItemSetEff.size(); x++)
|
||||
for (; x < player->ItemSetEff.size(); ++x)
|
||||
if (!player->ItemSetEff[x])
|
||||
break;
|
||||
|
||||
@@ -74,7 +72,7 @@ void AddItemsSetItem(Player*player,Item *item)
|
||||
|
||||
++eff->item_count;
|
||||
|
||||
for (uint32 x = 0; x < MAX_ITEM_SET_SPELLS; x++)
|
||||
for (uint32 x = 0; x < MAX_ITEM_SET_SPELLS; ++x)
|
||||
{
|
||||
if (!set->spells [x])
|
||||
continue;
|
||||
@@ -83,7 +81,7 @@ void AddItemsSetItem(Player*player,Item *item)
|
||||
continue;
|
||||
|
||||
uint32 z = 0;
|
||||
for (; z < MAX_ITEM_SET_SPELLS; z++)
|
||||
for (; z < MAX_ITEM_SET_SPELLS; ++z)
|
||||
if (eff->spells[z] && eff->spells[z]->Id == set->spells[x])
|
||||
break;
|
||||
|
||||
@@ -91,19 +89,19 @@ void AddItemsSetItem(Player*player,Item *item)
|
||||
continue;
|
||||
|
||||
//new spell
|
||||
for (uint32 y = 0; y < MAX_ITEM_SET_SPELLS; y++)
|
||||
for (uint32 y = 0; y < MAX_ITEM_SET_SPELLS; ++y)
|
||||
{
|
||||
if (!eff->spells[y]) // free slot
|
||||
{
|
||||
SpellEntry const *spellInfo = sSpellStore.LookupEntry(set->spells[x]);
|
||||
SpellEntry const* spellInfo = sSpellStore.LookupEntry(set->spells[x]);
|
||||
if (!spellInfo)
|
||||
{
|
||||
sLog->outError("WORLD: unknown spell id %u in items set %u effects", set->spells[x],setid);
|
||||
sLog->outError("WORLD: unknown spell id %u in items set %u effects", set->spells[x], setid);
|
||||
break;
|
||||
}
|
||||
|
||||
// spell casted only if fit form requirement, in other case will casted at form change
|
||||
player->ApplyEquipSpell(spellInfo,NULL,true);
|
||||
player->ApplyEquipSpell(spellInfo, NULL, true);
|
||||
eff->spells[y] = spellInfo;
|
||||
break;
|
||||
}
|
||||
@@ -870,8 +868,8 @@ bool Item::IsTargetValidForItemUse(Unit* pUnitTarget)
|
||||
|
||||
for (ConditionList::const_iterator itr = conditions.begin(); itr != conditions.end(); ++itr)
|
||||
{
|
||||
ACE_Auto_Ptr<ItemRequiredTarget> irt(new ItemRequiredTarget((ItemRequiredTargetType)(*itr)->mConditionValue1, (*itr)->mConditionValue2));
|
||||
if (irt->IsFitToRequirements(pUnitTarget))
|
||||
ItemRequiredTarget irt(ItemRequiredTargetType((*itr)->mConditionValue1), (*itr)->mConditionValue2);
|
||||
if (irt.IsFitToRequirements(pUnitTarget))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user