[11646] Implement support item converting at expire

Example: items 44623->44625->44627 convertion chain

* New table `item_enchantment_template` store original->final item pairs
  Original item must have duration setup.
* Small change in GetItemConvert for consistence (now 0 returned if no convert pair instead original entry id)

Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
cmaranec 2011-06-18 21:11:23 +04:00 committed by VladimirMangos
parent a97370a7f0
commit 2d7768a5ab
10 changed files with 117 additions and 13 deletions

View file

@ -2408,6 +2408,66 @@ void ObjectMgr::LoadItemConverts()
sLog.outString(">> Loaded %u Item converts", count);
}
void ObjectMgr::LoadItemExpireConverts()
{
m_ItemExpireConvert.clear(); // needed for reload case
uint32 count = 0;
QueryResult *result = WorldDatabase.Query("SELECT entry,item FROM item_expire_convert");
if (!result)
{
BarGoLink bar(1);
bar.step();
sLog.outString();
sLog.outErrorDb(">> Loaded 0 Item expire converts . DB table `item_expire_convert` is empty.");
return;
}
BarGoLink bar(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_expire_convert`: Item %u not exist in `item_template`.", itemEntry);
continue;
}
ItemPrototype const* pItemTargetProto = sItemStorage.LookupEntry<ItemPrototype>(itemTargetId);
if (!pItemTargetProto)
{
sLog.outErrorDb("Table `item_expire_convert`: Item target %u for original item %u not exist in `item_template`.", itemTargetId, itemEntry);
continue;
}
// Expire convert possible only for items with duration
if (pItemEntryProto->Duration == 0)
{
sLog.outErrorDb("Table `item_expire_convert` not appropriate item %u conversion to %u. Table can be used for items with duration.", itemEntry, itemTargetId);
continue;
}
m_ItemExpireConvert[itemEntry] = itemTargetId;
++count;
} while (result->NextRow());
delete result;
sLog.outString();
sLog.outString(">> Loaded %u Item expire converts", count);
}
void ObjectMgr::LoadItemRequiredTarget()
{