mirror of
https://github.com/mangosfour/server.git
synced 2025-12-25 13:37:02 +00:00
[7394] Check loot_template.maxcount for max allowed value (255) and make better report for this case.
Also optimize strcture LootStoreItem that let use 4 byte for loot template element in memory instead 5 bytes. But limit group id to 127 max value. Check this at loading.
This commit is contained in:
parent
be74937146
commit
42b5130931
4 changed files with 19 additions and 7 deletions
|
|
@ -114,11 +114,18 @@ void LootStore::LoadLootTable()
|
|||
float chanceOrQuestChance = fields[2].GetFloat();
|
||||
uint8 group = fields[3].GetUInt8();
|
||||
int32 mincountOrRef = fields[4].GetInt32();
|
||||
uint8 maxcount = fields[5].GetUInt8();
|
||||
uint32 maxcount = fields[5].GetUInt32();
|
||||
ConditionType condition = (ConditionType)fields[6].GetUInt8();
|
||||
uint32 cond_value1 = fields[7].GetUInt32();
|
||||
uint32 cond_value2 = fields[8].GetUInt32();
|
||||
|
||||
if(maxcount > std::numeric_limits<uint8>::max())
|
||||
{
|
||||
sLog.outErrorDb("Table '%s' entry %d item %d: maxcount value (%u) to large. must be less %u - skipped", GetName(), entry, maxcount,std::numeric_limits<uint8>::max());
|
||||
continue; // error already printed to log/console.
|
||||
}
|
||||
|
||||
|
||||
if(!PlayerCondition::IsValid(condition,cond_value1, cond_value2))
|
||||
{
|
||||
sLog.outErrorDb("... in table '%s' entry %u item %u", GetName(), entry, item);
|
||||
|
|
@ -248,6 +255,12 @@ bool LootStoreItem::Roll(bool rate) const
|
|||
// Checks correctness of values
|
||||
bool LootStoreItem::IsValid(LootStore const& store, uint32 entry) const
|
||||
{
|
||||
if(group >= 1 << 7) // it stored in 7 bit field
|
||||
{
|
||||
sLog.outErrorDb("Table '%s' entry %d item %d: group (%u) must be less %u - skipped", store.GetName(), entry, itemid, group, 1 << 7);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mincountOrRef == 0)
|
||||
{
|
||||
sLog.outErrorDb("Table '%s' entry %d item %d: wrong mincountOrRef (%d) - skipped", store.GetName(), entry, itemid, mincountOrRef);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue