mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
[8604] Consider random enchants in chatmessage validation
This commit is contained in:
parent
3e6b4b529e
commit
fe1560a483
4 changed files with 72 additions and 18 deletions
|
|
@ -1052,6 +1052,8 @@ valid examples:
|
||||||
Quest const* linkedQuest;
|
Quest const* linkedQuest;
|
||||||
SpellEntry const *linkedSpell;
|
SpellEntry const *linkedSpell;
|
||||||
AchievementEntry const* linkedAchievement;
|
AchievementEntry const* linkedAchievement;
|
||||||
|
ItemRandomPropertiesEntry const* itemProperty;
|
||||||
|
ItemRandomSuffixEntry const* itemSuffix;
|
||||||
|
|
||||||
while(!reader.eof())
|
while(!reader.eof())
|
||||||
{
|
{
|
||||||
|
|
@ -1061,6 +1063,8 @@ valid examples:
|
||||||
linkedQuest = NULL;
|
linkedQuest = NULL;
|
||||||
linkedSpell = NULL;
|
linkedSpell = NULL;
|
||||||
linkedAchievement = NULL;
|
linkedAchievement = NULL;
|
||||||
|
itemProperty = NULL;
|
||||||
|
itemSuffix = NULL;
|
||||||
|
|
||||||
reader.ignore(255, '|');
|
reader.ignore(255, '|');
|
||||||
}
|
}
|
||||||
|
|
@ -1177,9 +1181,47 @@ valid examples:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char c = reader.peek();
|
// the itementry is followed by several integers which describe an instance of this item
|
||||||
|
|
||||||
// ignore enchants etc.
|
// position relative after itemEntry
|
||||||
|
const uint8 randomPropertyPosition = 6;
|
||||||
|
|
||||||
|
int32 propertyId = 0;
|
||||||
|
bool negativeNumber = false;
|
||||||
|
char c;
|
||||||
|
for(uint8 i=0; i<randomPropertyPosition; ++i)
|
||||||
|
{
|
||||||
|
propertyId = 0;
|
||||||
|
negativeNumber = false;
|
||||||
|
while((c = reader.get())!=':')
|
||||||
|
{
|
||||||
|
if(c >='0' && c<='9')
|
||||||
|
{
|
||||||
|
propertyId*=10;
|
||||||
|
propertyId += c-'0';
|
||||||
|
} else if(c == '-')
|
||||||
|
negativeNumber = true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (negativeNumber)
|
||||||
|
propertyId *= -1;
|
||||||
|
|
||||||
|
if (propertyId > 0)
|
||||||
|
{
|
||||||
|
itemProperty = sItemRandomPropertiesStore.LookupEntry(propertyId);
|
||||||
|
if (!itemProperty)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if(propertyId < 0)
|
||||||
|
{
|
||||||
|
itemSuffix = sItemRandomSuffixStore.LookupEntry(-propertyId);
|
||||||
|
if (!itemSuffix)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ignore other integers
|
||||||
while ((c >= '0' && c <= '9') || c== ':')
|
while ((c >= '0' && c <= '9') || c== ':')
|
||||||
{
|
{
|
||||||
reader.ignore(1);
|
reader.ignore(1);
|
||||||
|
|
@ -1448,22 +1490,34 @@ valid examples:
|
||||||
}
|
}
|
||||||
else if(linkedItem)
|
else if(linkedItem)
|
||||||
{
|
{
|
||||||
if (strcmp(linkedItem->Name1, buffer) != 0)
|
char* const* suffix = itemSuffix?itemSuffix->nameSuffix:(itemProperty?itemProperty->nameSuffix:NULL);
|
||||||
|
|
||||||
|
std::string expectedName = std::string(linkedItem->Name1);
|
||||||
|
if (suffix)
|
||||||
|
{
|
||||||
|
expectedName += " ";
|
||||||
|
expectedName += suffix[LOCALE_enUS];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expectedName != buffer)
|
||||||
{
|
{
|
||||||
ItemLocale const *il = objmgr.GetItemLocale(linkedItem->ItemId);
|
ItemLocale const *il = objmgr.GetItemLocale(linkedItem->ItemId);
|
||||||
|
|
||||||
if (!il)
|
|
||||||
{
|
|
||||||
#ifdef MANGOS_DEBUG
|
|
||||||
sLog.outBasic("ChatHandler::isValidChatMessage linked item name doesn't is wrong and there is no localization");
|
|
||||||
#endif
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool foundName = false;
|
bool foundName = false;
|
||||||
for(uint8 i=0; i<il->Name.size(); ++i)
|
for(uint8 i=LOCALE_koKR; i<MAX_LOCALE; ++i)
|
||||||
{
|
{
|
||||||
if (il->Name[i] == buffer)
|
int8 dbIndex = objmgr.GetIndexForLocale(LocaleConstant(i));
|
||||||
|
if (dbIndex == -1 || il == NULL || dbIndex >= il->Name.size())
|
||||||
|
// using strange database/client combinations can lead to this case
|
||||||
|
expectedName = linkedItem->Name1;
|
||||||
|
else
|
||||||
|
expectedName = il->Name[dbIndex];
|
||||||
|
if (suffix)
|
||||||
|
{
|
||||||
|
expectedName += " ";
|
||||||
|
expectedName += suffix[i];
|
||||||
|
}
|
||||||
|
if ( expectedName == buffer)
|
||||||
{
|
{
|
||||||
foundName = true;
|
foundName = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -1027,14 +1027,14 @@ struct ItemRandomPropertiesEntry
|
||||||
uint32 ID; // 0 m_ID
|
uint32 ID; // 0 m_ID
|
||||||
//char* internalName // 1 m_Name
|
//char* internalName // 1 m_Name
|
||||||
uint32 enchant_id[5]; // 2-6 m_Enchantment
|
uint32 enchant_id[5]; // 2-6 m_Enchantment
|
||||||
//char* nameSuffix[16] // 7-22 m_name_lang
|
char* nameSuffix[16]; // 7-22 m_name_lang
|
||||||
// 23 name flags
|
// 23 name flags
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ItemRandomSuffixEntry
|
struct ItemRandomSuffixEntry
|
||||||
{
|
{
|
||||||
uint32 ID; // 0 m_ID
|
uint32 ID; // 0 m_ID
|
||||||
//char* name[16] // 1-16 m_name_lang
|
char* nameSuffix[16]; // 1-16 m_name_lang
|
||||||
// 17, name flags
|
// 17, name flags
|
||||||
// 18 m_internalName
|
// 18 m_internalName
|
||||||
uint32 enchant_id[5]; // 19-21 m_enchantment
|
uint32 enchant_id[5]; // 19-21 m_enchantment
|
||||||
|
|
|
||||||
|
|
@ -67,8 +67,8 @@ const char ItemBagFamilyfmt[]="nxxxxxxxxxxxxxxxxx";
|
||||||
//const char ItemCondExtCostsEntryfmt[]="xiii";
|
//const char ItemCondExtCostsEntryfmt[]="xiii";
|
||||||
const char ItemExtendedCostEntryfmt[]="niixiiiiiiiiiiix";
|
const char ItemExtendedCostEntryfmt[]="niixiiiiiiiiiiix";
|
||||||
const char ItemLimitCategoryEntryfmt[]="nxxxxxxxxxxxxxxxxxix";
|
const char ItemLimitCategoryEntryfmt[]="nxxxxxxxxxxxxxxxxxix";
|
||||||
const char ItemRandomPropertiesfmt[]="nxiiiiixxxxxxxxxxxxxxxxx";
|
const char ItemRandomPropertiesfmt[]="nxiiiiissssssssssssssssx";
|
||||||
const char ItemRandomSuffixfmt[]="nxxxxxxxxxxxxxxxxxxiiiiiiiiii";
|
const char ItemRandomSuffixfmt[]="nssssssssssssssssxxiiiiiiiiii";
|
||||||
const char ItemSetEntryfmt[]="dssssssssssssssssxxxxxxxxxxxxxxxxxxiiiiiiiiiiiiiiiiii";
|
const char ItemSetEntryfmt[]="dssssssssssssssssxxxxxxxxxxxxxxxxxxiiiiiiiiiiiiiiiiii";
|
||||||
const char LockEntryfmt[]="niiiiiiiiiiiiiiiiiiiiiiiixxxxxxxx";
|
const char LockEntryfmt[]="niiiiiiiiiiiiiiiiiiiiiiiixxxxxxxx";
|
||||||
const char MailTemplateEntryfmt[]="nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
|
const char MailTemplateEntryfmt[]="nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "8603"
|
#define REVISION_NR "8604"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue