Core/Items: Enforce item attributes stored in DBC files by default and add config option to allow overriding with database values, patch by ZxBiohazardZx.

Closes issue 4785.

--HG--
branch : trunk
This commit is contained in:
Shocker
2010-12-01 21:20:28 +02:00
parent a23ae5c94c
commit 0c44bd33ee
4 changed files with 32 additions and 15 deletions
+20 -15
View File
@@ -2030,6 +2030,7 @@ void ObjectMgr::LoadItemPrototypes()
sLog.outString();
// check data correctness
bool enforceDBCAttributes = sWorld.getBoolConfig(CONFIG_DBC_ENFORCE_ITEM_ATTRIBUTES);
for (uint32 i = 1; i < sItemStorage.MaxEntry; ++i)
{
ItemPrototype const* proto = sItemStorage.LookupEntry<ItemPrototype >(i);
@@ -2047,8 +2048,9 @@ void ObjectMgr::LoadItemPrototypes()
{
if (proto->Class != dbcitem->Class)
{
sLog.outErrorDb("Item (Entry: %u) does not have a correct class %u, must be %u (still using DB value).",i,proto->Class,dbcitem->Class);
// It is safe to use Class from DB
sLog.outErrorDb("Item (Entry: %u) does not have a correct class %u, must be %u .", i, proto->Class, dbcitem->Class);
if (enforceDBCAttributes)
const_cast<ItemPrototype*>(proto)->Class = dbcitem->Class;
}
/* disabled: have some strange wrong cases for Subclass values.
for enable also uncomment Subclass field in ItemEntry structure and in Itemfmt[]
@@ -2061,32 +2063,35 @@ void ObjectMgr::LoadItemPrototypes()
if (proto->Unk0 != dbcitem->Unk0)
{
sLog.outErrorDb("Item (Entry: %u) does not have a correct Unk0 (%i) , must be %i (still using DB value).",i,proto->Unk0,dbcitem->Unk0);
// It is safe to use Unk0 from DB
sLog.outErrorDb("Item (Entry: %u) does not have a correct Unk0 (%i) , must be %i .", i, proto->Unk0, dbcitem->Unk0);
if (enforceDBCAttributes)
const_cast<ItemPrototype*>(proto)->Unk0 = dbcitem->Unk0;
}
if (proto->Material != dbcitem->Material)
{
sLog.outErrorDb("Item (Entry: %u) does not have a correct material (%i), must be %i (still using DB value).",i,proto->Material,dbcitem->Material);
// It is safe to use Material from DB
sLog.outErrorDb("Item (Entry: %u) does not have a correct material (%i), must be %i .", i, proto->Material, dbcitem->Material);
if (enforceDBCAttributes)
const_cast<ItemPrototype*>(proto)->Material = dbcitem->Material;
}
if (proto->InventoryType != dbcitem->InventoryType)
{
sLog.outErrorDb("Item (Entry: %u) does not have a correct inventory type (%u), must be %u (still using DB value).",i,proto->InventoryType,dbcitem->InventoryType);
// It is safe to use InventoryType from DB
sLog.outErrorDb("Item (Entry: %u) does not have a correct inventory type (%u), must be %u .", i, proto->InventoryType, dbcitem->InventoryType);
if (enforceDBCAttributes)
const_cast<ItemPrototype*>(proto)->InventoryType = dbcitem->InventoryType;
}
if (proto->DisplayInfoID != dbcitem->DisplayId)
{
sLog.outErrorDb("Item (Entry: %u) does not have a correct display id (%u), must be %u (using it).",i,proto->DisplayInfoID,dbcitem->DisplayId);
const_cast<ItemPrototype*>(proto)->DisplayInfoID = dbcitem->DisplayId;
sLog.outErrorDb("Item (Entry: %u) does not have a correct display id (%u), must be %u .", i, proto->DisplayInfoID, dbcitem->DisplayId);
if (enforceDBCAttributes)
const_cast<ItemPrototype*>(proto)->DisplayInfoID = dbcitem->DisplayId;
}
if (proto->Sheath != dbcitem->Sheath)
{
sLog.outErrorDb("Item (Entry: %u) does not have a correct sheathid (%u), must be %u (using it).",i,proto->Sheath,dbcitem->Sheath);
const_cast<ItemPrototype*>(proto)->Sheath = dbcitem->Sheath;
sLog.outErrorDb("Item (Entry: %u) does not have a correct sheathid (%u), must be %u .", i, proto->Sheath, dbcitem->Sheath);
if (enforceDBCAttributes)
const_cast<ItemPrototype*>(proto)->Sheath = dbcitem->Sheath;
}
}
else
sLog.outErrorDb("Item (Entry: %u) does not exist in item.dbc! (not correct id?).",i);
+3
View File
@@ -1172,6 +1172,9 @@ void World::LoadConfigSettings(bool reload)
// Dungeon finder
m_bool_configs[CONFIG_DUNGEON_FINDER_ENABLE] = sConfig.GetBoolDefault("DungeonFinder.Enable", false);
// DBC_ItemAttributes
m_bool_configs[CONFIG_DBC_ENFORCE_ITEM_ATTRIBUTES] = sConfig.GetBoolDefault("DBC.EnforceItemAttributes", true);
// AutoBroadcast
m_bool_configs[CONFIG_AUTOBROADCAST] = sConfig.GetBoolDefault("AutoBroadcast.On", false);
+1
View File
@@ -162,6 +162,7 @@ enum WorldBoolConfigs
CONFIG_DUNGEON_FINDER_ENABLE,
CONFIG_AUTOBROADCAST,
CONFIG_ALLOW_TICKETS,
CONFIG_DBC_ENFORCE_ITEM_ATTRIBUTES,
BOOL_CONFIG_VALUE_COUNT
};
@@ -1369,6 +1369,14 @@ AllowTickets = 1
DungeonFinder.Enable = 0
#
# DBC.EnforceItemAttributes
# Disallow overriding item attributes stored in DBC files with values from the database
# Default: 0 - Off, Use DB values
# 1 - On, Enforce DBC Values (default)
DBC.EnforceItemAttributes = 1
#
###################################################################################################