diff options
author | jackpoz <giacomopoz@gmail.com> | 2015-11-19 20:23:09 +0100 |
---|---|---|
committer | jackpoz <giacomopoz@gmail.com> | 2015-11-19 20:23:09 +0100 |
commit | 0e9f714a097bb9a5f16c4883e26f19db0dea9a1b (patch) | |
tree | 12de97061b5c7224e63aca9685a79d21a2c5c2b1 | |
parent | f012800751396309e75d0baf4ed3406855c8e93a (diff) |
Core/Items: Fix crash
Fix crash happening if item_template.StatsCount field in the database was higher than 10.
Fixes #15868
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 046ce422cd2..b2be5c49b91 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -2347,6 +2347,12 @@ void ObjectMgr::LoadItemTemplates() itemTemplate.ContainerSlots = uint32(fields[26].GetUInt8()); itemTemplate.StatsCount = uint32(fields[27].GetUInt8()); + if (itemTemplate.StatsCount > MAX_ITEM_PROTO_STATS) + { + TC_LOG_ERROR("sql.sql", "Item (Entry: %u) has too large value in statscount (%u), replace by hardcoded limit (%u).", entry, itemTemplate.StatsCount, MAX_ITEM_PROTO_STATS); + itemTemplate.StatsCount = MAX_ITEM_PROTO_STATS; + } + for (uint8 i = 0; i < itemTemplate.StatsCount; ++i) { itemTemplate.ItemStat[i].ItemStatType = uint32(fields[28 + i*2].GetUInt8()); @@ -2594,12 +2600,6 @@ void ObjectMgr::LoadItemTemplates() itemTemplate.ContainerSlots = MAX_BAG_SIZE; } - if (itemTemplate.StatsCount > MAX_ITEM_PROTO_STATS) - { - TC_LOG_ERROR("sql.sql", "Item (Entry: %u) has too large value in statscount (%u), replace by hardcoded limit (%u).", entry, itemTemplate.StatsCount, MAX_ITEM_PROTO_STATS); - itemTemplate.StatsCount = MAX_ITEM_PROTO_STATS; - } - for (uint8 j = 0; j < itemTemplate.StatsCount; ++j) { // for ItemStatValue != 0 |