From 4f6c96b98c5d5a065f902aa6106c928bf0b2a668 Mon Sep 17 00:00:00 2001 From: megamage Date: Fri, 6 Mar 2009 19:39:42 -0600 Subject: [7394] Check loot_template.maxcount for max allowed value (255) and make better report for this case. Author: VladimirMangos 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. --HG-- branch : trunk --- src/game/LootMgr.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/game/LootMgr.cpp') diff --git a/src/game/LootMgr.cpp b/src/game/LootMgr.cpp index da5b4343d24..046fa28f106 100644 --- a/src/game/LootMgr.cpp +++ b/src/game/LootMgr.cpp @@ -117,11 +117,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::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::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); @@ -251,6 +258,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); -- cgit v1.2.3