Allow to sell item for: money, extendedCost or money+extendedCost.

The new method (money+extende) can be used by using negative values on npc_vendor.ExtendedCost.
This one goes dedicated to ZxBiohazardZx.
Tnx also to VladimirMangos.

--HG--
branch : trunk
This commit is contained in:
John Holiver
2010-06-09 19:38:15 -03:00
parent 410eb3d1b6
commit 5dff68e457
9 changed files with 45 additions and 34 deletions
+8 -4
View File
@@ -307,13 +307,17 @@ enum ChatType
// Vendors
struct VendorItem
{
VendorItem(uint32 _item, int32 _maxcount, uint32 _incrtime, uint32 _ExtendedCost)
VendorItem(uint32 _item, int32 _maxcount, uint32 _incrtime, int32 _ExtendedCost)
: item(_item), maxcount(_maxcount), incrtime(_incrtime), ExtendedCost(_ExtendedCost) {}
uint32 item;
int32 maxcount; // 0 for infinity item amount
uint32 incrtime; // time for restore items amount if maxcount != 0
uint32 ExtendedCost;
int32 ExtendedCost;
//helpers
bool IsExcludeMoneyPrice() const { return ExtendedCost > 0; }
uint32 GetExtendedCostId() const { return std::abs(ExtendedCost); }
};
typedef std::vector<VendorItem*> VendorItemList;
@@ -328,12 +332,12 @@ struct VendorItemData
}
bool Empty() const { return m_items.empty(); }
uint8 GetItemCount() const { return m_items.size(); }
void AddItem(uint32 item, int32 maxcount, uint32 ptime, uint32 ExtendedCost)
void AddItem(uint32 item, int32 maxcount, uint32 ptime, int32 ExtendedCost)
{
m_items.push_back(new VendorItem(item, maxcount, ptime, ExtendedCost));
}
bool RemoveItem(uint32 item_id);
VendorItem const* FindItemCostPair(uint32 item_id, uint32 extendedCost) const;
VendorItem const* FindItemCostPair(uint32 item_id, int32 extendedCost) const;
void Clear()
{
for (VendorItemList::const_iterator itr = m_items.begin(); itr != m_items.end(); ++itr)