[10682] New table 'item_convert' for convertion items.

* Implment vendor at show replace BoA item with reputation requirement
  by identical item without rep. reqs for player that fit this requirements
  of original item.

* Table also can be used for store item convertion data form one team items
  to similar other team items. This case not impement but added function easy
  used for it.

* Note: strict single convert for item not created problem for both way use:
  item converted for same team or all, can't be original item for conversion to
  another team.
This commit is contained in:
VladimirMangos 2010-11-04 23:53:23 +03:00
parent 225b4db1ca
commit 2f144d9d29
13 changed files with 162 additions and 6 deletions

View file

@ -2393,6 +2393,72 @@ void ObjectMgr::LoadItemPrototypes()
sLog.outErrorDb("Item (Entry: %u) not exist in `item_template` but referenced in `CharStartOutfit.dbc`", *itr);
}
void ObjectMgr::LoadItemConverts()
{
m_ItemRequiredTarget.clear(); // needed for reload case
uint32 count = 0;
QueryResult *result = WorldDatabase.Query("SELECT entry,item FROM item_convert");
if (!result)
{
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outErrorDb(">> Loaded 0 Item converts . DB table `item_convert` is empty.");
return;
}
barGoLink bar((int)result->GetRowCount());
do
{
Field *fields = result->Fetch();
bar.step();
uint32 itemEntry = fields[0].GetUInt32();
uint32 itemTargetId = fields[1].GetUInt32();
ItemPrototype const* pItemEntryProto = sItemStorage.LookupEntry<ItemPrototype>(itemEntry);
if (!pItemEntryProto)
{
sLog.outErrorDb("Table `item_convert`: Item %u not exist in `item_template`.", itemEntry);
continue;
}
ItemPrototype const* pItemTargetProto = sItemStorage.LookupEntry<ItemPrototype>(itemTargetId);
if (!pItemTargetProto)
{
sLog.outErrorDb("Table `item_convert`: Item target %u for original item %u not exist in `item_template`.", itemTargetId, itemEntry);
continue;
}
// 2 cases when item convert used
// Boa item with reputation requirement
if ((!(pItemEntryProto->Flags & ITEM_FLAG_BOA) || !pItemEntryProto->RequiredReputationFaction) &&
// convertion to another team/race
(pItemTargetProto->AllowableRace & pItemEntryProto->AllowableRace))
{
sLog.outErrorDb("Table `item_convert` not appropriate item %u conversion to %u. Table can be used for BoA items requirement drop or for conversion to another race/team use.", itemEntry, itemTargetId);
continue;
}
m_ItemConvert[itemEntry] = itemTargetId;
++count;
} while (result->NextRow());
delete result;
sLog.outString();
sLog.outString(">> Loaded %u Item converts", count);
}
void ObjectMgr::LoadItemRequiredTarget()
{
m_ItemRequiredTarget.clear(); // needed for reload case