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(); sLog.outString();
// check data correctness // check data correctness
bool enforceDBCAttributes = sWorld.getBoolConfig(CONFIG_DBC_ENFORCE_ITEM_ATTRIBUTES);
for (uint32 i = 1; i < sItemStorage.MaxEntry; ++i) for (uint32 i = 1; i < sItemStorage.MaxEntry; ++i)
{ {
ItemPrototype const* proto = sItemStorage.LookupEntry<ItemPrototype >(i); ItemPrototype const* proto = sItemStorage.LookupEntry<ItemPrototype >(i);
@@ -2047,8 +2048,9 @@ void ObjectMgr::LoadItemPrototypes()
{ {
if (proto->Class != dbcitem->Class) 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); sLog.outErrorDb("Item (Entry: %u) does not have a correct class %u, must be %u .", i, proto->Class, dbcitem->Class);
// It is safe to use Class from DB if (enforceDBCAttributes)
const_cast<ItemPrototype*>(proto)->Class = dbcitem->Class;
} }
/* disabled: have some strange wrong cases for Subclass values. /* disabled: have some strange wrong cases for Subclass values.
for enable also uncomment Subclass field in ItemEntry structure and in Itemfmt[] for enable also uncomment Subclass field in ItemEntry structure and in Itemfmt[]
@@ -2061,32 +2063,35 @@ void ObjectMgr::LoadItemPrototypes()
if (proto->Unk0 != dbcitem->Unk0) 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); sLog.outErrorDb("Item (Entry: %u) does not have a correct Unk0 (%i) , must be %i .", i, proto->Unk0, dbcitem->Unk0);
// It is safe to use Unk0 from DB if (enforceDBCAttributes)
const_cast<ItemPrototype*>(proto)->Unk0 = dbcitem->Unk0;
} }
if (proto->Material != dbcitem->Material) 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); sLog.outErrorDb("Item (Entry: %u) does not have a correct material (%i), must be %i .", i, proto->Material, dbcitem->Material);
// It is safe to use Material from DB if (enforceDBCAttributes)
const_cast<ItemPrototype*>(proto)->Material = dbcitem->Material;
} }
if (proto->InventoryType != dbcitem->InventoryType) 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); sLog.outErrorDb("Item (Entry: %u) does not have a correct inventory type (%u), must be %u .", i, proto->InventoryType, dbcitem->InventoryType);
// It is safe to use InventoryType from DB if (enforceDBCAttributes)
const_cast<ItemPrototype*>(proto)->InventoryType = dbcitem->InventoryType;
} }
if (proto->DisplayInfoID != dbcitem->DisplayId) 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); sLog.outErrorDb("Item (Entry: %u) does not have a correct display id (%u), must be %u .", i, proto->DisplayInfoID, dbcitem->DisplayId);
const_cast<ItemPrototype*>(proto)->DisplayInfoID = dbcitem->DisplayId; if (enforceDBCAttributes)
const_cast<ItemPrototype*>(proto)->DisplayInfoID = dbcitem->DisplayId;
} }
if (proto->Sheath != dbcitem->Sheath) 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); sLog.outErrorDb("Item (Entry: %u) does not have a correct sheathid (%u), must be %u .", i, proto->Sheath, dbcitem->Sheath);
const_cast<ItemPrototype*>(proto)->Sheath = dbcitem->Sheath; if (enforceDBCAttributes)
const_cast<ItemPrototype*>(proto)->Sheath = dbcitem->Sheath;
} }
} }
else else
sLog.outErrorDb("Item (Entry: %u) does not exist in item.dbc! (not correct id?).",i); sLog.outErrorDb("Item (Entry: %u) does not exist in item.dbc! (not correct id?).",i);
+3
View File
@@ -1173,6 +1173,9 @@ void World::LoadConfigSettings(bool reload)
// Dungeon finder // Dungeon finder
m_bool_configs[CONFIG_DUNGEON_FINDER_ENABLE] = sConfig.GetBoolDefault("DungeonFinder.Enable", false); 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 // AutoBroadcast
m_bool_configs[CONFIG_AUTOBROADCAST] = sConfig.GetBoolDefault("AutoBroadcast.On", false); m_bool_configs[CONFIG_AUTOBROADCAST] = sConfig.GetBoolDefault("AutoBroadcast.On", false);
m_int_configs[CONFIG_AUTOBROADCAST_CENTER] = sConfig.GetIntDefault("AutoBroadcast.Center", 0); m_int_configs[CONFIG_AUTOBROADCAST_CENTER] = sConfig.GetIntDefault("AutoBroadcast.Center", 0);
+1
View File
@@ -162,6 +162,7 @@ enum WorldBoolConfigs
CONFIG_DUNGEON_FINDER_ENABLE, CONFIG_DUNGEON_FINDER_ENABLE,
CONFIG_AUTOBROADCAST, CONFIG_AUTOBROADCAST,
CONFIG_ALLOW_TICKETS, CONFIG_ALLOW_TICKETS,
CONFIG_DBC_ENFORCE_ITEM_ATTRIBUTES,
BOOL_CONFIG_VALUE_COUNT BOOL_CONFIG_VALUE_COUNT
}; };
@@ -1369,6 +1369,14 @@ AllowTickets = 1
DungeonFinder.Enable = 0 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
# #
################################################################################################### ###################################################################################################