mirror of
https://github.com/mangosfour/server.git
synced 2025-12-28 13:37:13 +00:00
[12216] Implement currency loot and update loot opcodes.
Now negative item value in loot tables represent currency id. Signed-off-by: Yaki Khadafi <elsoldollo@gmail.com>
This commit is contained in:
parent
f710cc3c24
commit
ef0f63e05b
31 changed files with 418 additions and 160 deletions
|
|
@ -648,7 +648,8 @@ bool Item::LoadFromDB(uint32 guidLow, Field* fields, ObjectGuid ownerGuid)
|
|||
|
||||
void Item::LoadLootFromDB(Field* fields)
|
||||
{
|
||||
uint32 item_id = fields[1].GetUInt32();
|
||||
uint32 item_id = abs(fields[1].GetInt32());
|
||||
uint8 type = fields[1].GetInt32() > 0 ? LOOT_ITEM_TYPE_ITEM : LOOT_ITEM_TYPE_CURRENCY;
|
||||
uint32 item_amount = fields[2].GetUInt32();
|
||||
uint32 item_suffix = fields[3].GetUInt32();
|
||||
int32 item_propid = fields[4].GetInt32();
|
||||
|
|
@ -662,16 +663,32 @@ void Item::LoadLootFromDB(Field* fields)
|
|||
}
|
||||
|
||||
// normal item case
|
||||
ItemPrototype const* proto = ObjectMgr::GetItemPrototype(item_id);
|
||||
|
||||
if (!proto)
|
||||
if (type == LOOT_ITEM_TYPE_ITEM)
|
||||
{
|
||||
CharacterDatabase.PExecute("DELETE FROM item_loot WHERE guid = '%u' AND itemid = '%u'", GetGUIDLow(), item_id);
|
||||
sLog.outError("Item::LoadLootFromDB: %s has an unknown item (id: #%u) in item_loot, deleted.", GetOwnerGuid().GetString().c_str(), item_id);
|
||||
return;
|
||||
ItemPrototype const* proto = ObjectMgr::GetItemPrototype(item_id);
|
||||
if (!proto)
|
||||
{
|
||||
CharacterDatabase.PExecute("DELETE FROM item_loot WHERE guid = '%u' AND itemid = '%u'", GetGUIDLow(), item_id);
|
||||
sLog.outError("Item::LoadLootFromDB: %s has an unknown item (id: #%u) in item_loot, deleted.", GetOwnerGuid().GetString().c_str(), item_id);
|
||||
return;
|
||||
}
|
||||
|
||||
loot.items.push_back(LootItem(item_id, type, item_amount, item_suffix, item_propid));
|
||||
}
|
||||
// currency case
|
||||
else //if (type == LOOT_ITEM_TYPE_CURRENCY)
|
||||
{
|
||||
CurrencyTypesEntry const* currencyEntry = sCurrencyTypesStore.LookupEntry(item_id);
|
||||
if (!currencyEntry)
|
||||
{
|
||||
CharacterDatabase.PExecute("DELETE FROM item_loot WHERE guid = '%u' AND itemid = '%i'", GetGUIDLow(), -int32(item_id));
|
||||
sLog.outError("Item::LoadLootFromDB: %s has an unknown currency (id: #%u) in item_loot, deleted.", GetOwnerGuid().GetString().c_str(), item_id);
|
||||
return;
|
||||
}
|
||||
|
||||
loot.items.push_back(LootItem(item_id, type, item_amount));
|
||||
}
|
||||
|
||||
loot.items.push_back(LootItem(item_id, item_amount, item_suffix, item_propid));
|
||||
++loot.unlootedCount;
|
||||
|
||||
SetLootState(ITEM_LOOT_UNCHANGED);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue