Revert revisions 67325b1a0af0 and a0cba24b9060.
Made vendors ignore gold cost by default when extended cost is set, except when item has ITEM_FLAGS_EXTRA_EXT_COST_REQUIRES_GOLD flag --HG-- branch : trunk
This commit is contained in:
@@ -1051,7 +1051,7 @@ bool ChatHandler::HandleNpcAddVendorItemCommand(const char* args)
|
||||
incrtime = atol(fincrtime);
|
||||
|
||||
char* fextendedcost = strtok(NULL, " "); //add ExtendedCost, default: 0
|
||||
int32 extendedcost = fextendedcost ? atol(fextendedcost) : 0;
|
||||
uint32 extendedcost = fextendedcost ? atol(fextendedcost) : 0;
|
||||
|
||||
Creature* vendor = getSelectedCreature();
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ bool VendorItemData::RemoveItem(uint32 item_id)
|
||||
return found;
|
||||
}
|
||||
|
||||
VendorItem const* VendorItemData::FindItemCostPair(uint32 item_id, int32 extendedCost) const
|
||||
VendorItem const* VendorItemData::FindItemCostPair(uint32 item_id, uint32 extendedCost) const
|
||||
{
|
||||
for (VendorItemList::const_iterator i = m_items.begin(); i != m_items.end(); ++i)
|
||||
if((*i)->item == item_id && (*i)->ExtendedCost == extendedCost)
|
||||
|
||||
@@ -307,17 +307,16 @@ enum ChatType
|
||||
// Vendors
|
||||
struct VendorItem
|
||||
{
|
||||
VendorItem(uint32 _item, int32 _maxcount, uint32 _incrtime, int32 _ExtendedCost)
|
||||
VendorItem(uint32 _item, int32 _maxcount, uint32 _incrtime, uint32 _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
|
||||
int32 ExtendedCost;
|
||||
uint32 ExtendedCost;
|
||||
|
||||
//helpers
|
||||
bool IsExcludeMoneyPrice() const { return ExtendedCost > 0; }
|
||||
uint32 GetExtendedCostId() const { return std::abs(ExtendedCost); }
|
||||
bool IsGoldRequired(ItemPrototype const* pProto) const { return pProto->Flags2 & ITEM_FLAGS_EXTRA_EXT_COST_REQUIRES_GOLD || !ExtendedCost; }
|
||||
};
|
||||
typedef std::vector<VendorItem*> VendorItemList;
|
||||
|
||||
@@ -332,12 +331,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, int32 ExtendedCost)
|
||||
void AddItem(uint32 item, int32 maxcount, uint32 ptime, uint32 ExtendedCost)
|
||||
{
|
||||
m_items.push_back(new VendorItem(item, maxcount, ptime, ExtendedCost));
|
||||
}
|
||||
bool RemoveItem(uint32 item_id);
|
||||
VendorItem const* FindItemCostPair(uint32 item_id, int32 extendedCost) const;
|
||||
VendorItem const* FindItemCostPair(uint32 item_id, uint32 extendedCost) const;
|
||||
void Clear()
|
||||
{
|
||||
for (VendorItemList::const_iterator itr = m_items.begin(); itr != m_items.end(); ++itr)
|
||||
|
||||
@@ -136,7 +136,7 @@ enum ItemFlagsExtra
|
||||
{
|
||||
ITEM_FLAGS_EXTRA_HORDE_ONLY = 0x00000001,
|
||||
ITEM_FLAGS_EXTRA_ALLIANCE_ONLY = 0x00000002,
|
||||
ITEM_FLAGS_EXTRA_REFUNDABLE = 0x00000004,
|
||||
ITEM_FLAGS_EXTRA_EXT_COST_REQUIRES_GOLD = 0x00000004, // when item uses extended cost, gold is also required
|
||||
ITEM_FLAGS_EXTRA_NEED_ROLL_DISABLED = 0x00000100
|
||||
};
|
||||
|
||||
|
||||
@@ -19655,12 +19655,12 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32
|
||||
return false;
|
||||
}
|
||||
|
||||
if (uint32 extendedCostId = crItem->GetExtendedCostId())
|
||||
if (crItem->ExtendedCost)
|
||||
{
|
||||
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(extendedCostId);
|
||||
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost);
|
||||
if (!iece)
|
||||
{
|
||||
sLog.outError("Item %u have wrong ExtendedCost field value %u", pProto->ItemId, extendedCostId);
|
||||
sLog.outError("Item %u have wrong ExtendedCost field value %u", pProto->ItemId, crItem->ExtendedCost);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -19697,7 +19697,7 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32
|
||||
}
|
||||
}
|
||||
|
||||
int32 price = crItem->IsExcludeMoneyPrice() ? 0 : pProto->BuyPrice * count;
|
||||
int32 price = crItem->IsGoldRequired(pProto) ? pProto->BuyPrice * count : 0;
|
||||
|
||||
// reputation discount
|
||||
if (price)
|
||||
@@ -19721,9 +19721,9 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32
|
||||
|
||||
ModifyMoney(-(int32)price);
|
||||
|
||||
if (uint32 extendedCostId = crItem->GetExtendedCostId()) // case for new honor system
|
||||
if (crItem->ExtendedCost) // case for new honor system
|
||||
{
|
||||
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(extendedCostId);
|
||||
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost);
|
||||
if (iece->reqhonorpoints)
|
||||
ModifyHonorPoints(- int32(iece->reqhonorpoints * count));
|
||||
|
||||
@@ -19749,11 +19749,11 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32
|
||||
GetSession()->SendPacket(&data);
|
||||
SendNewItem(it, pProto->BuyCount*count, true, false, false);
|
||||
|
||||
if (it->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_REFUNDABLE) && crItem->GetExtendedCostId())
|
||||
if (it->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_REFUNDABLE) && crItem->ExtendedCost)
|
||||
{
|
||||
it->SetRefundRecipient(GetGUIDLow());
|
||||
it->SetPaidMoney(price);
|
||||
it->SetPaidExtendedCost(crItem->GetExtendedCostId());
|
||||
it->SetPaidExtendedCost(crItem->ExtendedCost);
|
||||
it->SaveRefundDataToDB();
|
||||
AddRefundReference(it->GetGUIDLow());
|
||||
}
|
||||
@@ -19776,9 +19776,9 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32
|
||||
}
|
||||
|
||||
ModifyMoney(-(int32)price);
|
||||
if (uint32 extendedCostId = crItem->GetExtendedCostId()) // case for new honor system
|
||||
if (crItem->ExtendedCost) // case for new honor system
|
||||
{
|
||||
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(extendedCostId);
|
||||
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost);
|
||||
if (iece->reqhonorpoints)
|
||||
ModifyHonorPoints(- int32(iece->reqhonorpoints * count));
|
||||
|
||||
@@ -19807,11 +19807,11 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32
|
||||
|
||||
AutoUnequipOffhandIfNeed();
|
||||
|
||||
if (it->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_REFUNDABLE) && crItem->GetExtendedCostId())
|
||||
if (it->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_REFUNDABLE) && crItem->ExtendedCost)
|
||||
{
|
||||
it->SetRefundRecipient(GetGUIDLow());
|
||||
it->SetPaidMoney(price);
|
||||
it->SetPaidExtendedCost(crItem->GetExtendedCostId());
|
||||
it->SetPaidExtendedCost(crItem->ExtendedCost);
|
||||
it->SaveRefundDataToDB();
|
||||
AddRefundReference(it->GetGUIDLow());
|
||||
}
|
||||
|
||||
@@ -8089,14 +8089,14 @@ int ObjectMgr::LoadReferenceVendor(int32 vendor, int32 item, std::set<uint32> *s
|
||||
{
|
||||
int32 maxcount = fields[1].GetInt32();
|
||||
uint32 incrtime = fields[2].GetUInt32();
|
||||
int32 ExtendedCost = fields[3].GetUInt32();
|
||||
uint32 ExtendedCost = fields[3].GetUInt32();
|
||||
|
||||
if (!IsVendorItemValid(vendor,item_id,maxcount,incrtime,ExtendedCost,NULL,skip_vendors))
|
||||
if (!IsVendorItemValid(vendor, item_id, maxcount, incrtime, ExtendedCost, NULL, skip_vendors))
|
||||
continue;
|
||||
|
||||
VendorItemData& vList = m_mCacheVendorItemMap[vendor];
|
||||
|
||||
vList.AddItem(item_id,maxcount,incrtime,ExtendedCost);
|
||||
vList.AddItem(item_id, maxcount, incrtime, ExtendedCost);
|
||||
++count;
|
||||
}
|
||||
|
||||
@@ -8144,14 +8144,14 @@ void ObjectMgr::LoadVendors()
|
||||
{
|
||||
int32 maxcount = fields[2].GetInt32();
|
||||
uint32 incrtime = fields[3].GetUInt32();
|
||||
int32 ExtendedCost = fields[4].GetUInt32();
|
||||
uint32 ExtendedCost = fields[4].GetUInt32();
|
||||
|
||||
if (!IsVendorItemValid(entry,item_id,maxcount,incrtime,ExtendedCost,NULL,&skip_vendors))
|
||||
if (!IsVendorItemValid(entry, item_id, maxcount, incrtime, ExtendedCost, NULL, &skip_vendors))
|
||||
continue;
|
||||
|
||||
VendorItemData& vList = m_mCacheVendorItemMap[entry];
|
||||
|
||||
vList.AddItem(item_id,maxcount,incrtime,ExtendedCost);
|
||||
vList.AddItem(item_id, maxcount, incrtime, ExtendedCost);
|
||||
++count;
|
||||
}
|
||||
|
||||
@@ -8358,12 +8358,13 @@ void ObjectMgr::LoadGossipMenuItems()
|
||||
sLog.outString(">> Loaded %u gossip_menu_option entries", count);
|
||||
}
|
||||
|
||||
void ObjectMgr::AddVendorItem(uint32 entry,uint32 item, int32 maxcount, uint32 incrtime, int32 extendedcost, bool savetodb)
|
||||
void ObjectMgr::AddVendorItem(uint32 entry,uint32 item, int32 maxcount, uint32 incrtime, uint32 extendedcost, bool savetodb)
|
||||
{
|
||||
VendorItemData& vList = m_mCacheVendorItemMap[entry];
|
||||
vList.AddItem(item,maxcount,incrtime,extendedcost);
|
||||
vList.AddItem(item, maxcount, incrtime, extendedcost);
|
||||
|
||||
if (savetodb) WorldDatabase.PExecuteLog("INSERT INTO npc_vendor (entry,item,maxcount,incrtime,extendedcost) VALUES('%u','%u','%u','%u','%i')",entry, item, maxcount,incrtime,extendedcost);
|
||||
if (savetodb)
|
||||
WorldDatabase.PExecuteLog("INSERT INTO npc_vendor (entry,item,maxcount,incrtime,extendedcost) VALUES('%u','%u','%u','%u','%i')", entry, item, maxcount, incrtime, extendedcost);
|
||||
}
|
||||
|
||||
bool ObjectMgr::RemoveVendorItem(uint32 entry,uint32 item, bool savetodb)
|
||||
@@ -8379,7 +8380,7 @@ bool ObjectMgr::RemoveVendorItem(uint32 entry,uint32 item, bool savetodb)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 maxcount, uint32 incrtime, int32 ExtendedCost, Player* pl, std::set<uint32>* skip_vendors, uint32 ORnpcflag) const
|
||||
bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 maxcount, uint32 incrtime, uint32 ExtendedCost, Player* pl, std::set<uint32>* skip_vendors, uint32 ORnpcflag) const
|
||||
{
|
||||
CreatureInfo const* cInfo = GetCreatureTemplate(vendor_entry);
|
||||
if (!cInfo)
|
||||
@@ -8411,17 +8412,16 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max
|
||||
if (pl)
|
||||
ChatHandler(pl).PSendSysMessage(LANG_ITEM_NOT_FOUND, item_id);
|
||||
else
|
||||
sLog.outErrorDb("Table `(game_event_)npc_vendor` for Vendor (Entry: %u) have in item list non-existed item (%u), ignore",vendor_entry,item_id);
|
||||
sLog.outErrorDb("Table `(game_event_)npc_vendor` for Vendor (Entry: %u) have in item list non-existed item (%u), ignore", vendor_entry, item_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 extendedCostId = std::abs(ExtendedCost);
|
||||
if (extendedCostId && !sItemExtendedCostStore.LookupEntry(extendedCostId))
|
||||
if (ExtendedCost && !sItemExtendedCostStore.LookupEntry(ExtendedCost))
|
||||
{
|
||||
if (pl)
|
||||
ChatHandler(pl).PSendSysMessage(LANG_EXTENDED_COST_NOT_EXIST,extendedCostId);
|
||||
ChatHandler(pl).PSendSysMessage(LANG_EXTENDED_COST_NOT_EXIST, ExtendedCost);
|
||||
else
|
||||
sLog.outErrorDb("Table `(game_event_)npc_vendor` have Item (Entry: %u) with wrong ExtendedCost (%u) for vendor (%u), ignore",item_id,extendedCostId,vendor_entry);
|
||||
sLog.outErrorDb("Table `(game_event_)npc_vendor` have Item (Entry: %u) with wrong ExtendedCost (%u) for vendor (%u), ignore", item_id, ExtendedCost, vendor_entry);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -8449,9 +8449,9 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max
|
||||
if (vItems->FindItemCostPair(item_id, ExtendedCost))
|
||||
{
|
||||
if (pl)
|
||||
ChatHandler(pl).PSendSysMessage(LANG_ITEM_ALREADY_IN_LIST, item_id, extendedCostId);
|
||||
ChatHandler(pl).PSendSysMessage(LANG_ITEM_ALREADY_IN_LIST, item_id, ExtendedCost);
|
||||
else
|
||||
sLog.outErrorDb( "Table `npc_vendor` has duplicate items %u (with extended cost %u) for vendor (Entry: %u), ignoring", item_id, extendedCostId, vendor_entry);
|
||||
sLog.outErrorDb( "Table `npc_vendor` has duplicate items %u (with extended cost %u) for vendor (Entry: %u), ignoring", item_id, ExtendedCost, vendor_entry);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -882,9 +882,9 @@ class ObjectMgr
|
||||
|
||||
return &iter->second;
|
||||
}
|
||||
void AddVendorItem(uint32 entry,uint32 item, int32 maxcount, uint32 incrtime, int32 ExtendedCost, bool savetodb = true); // for event
|
||||
bool RemoveVendorItem(uint32 entry,uint32 item, bool savetodb = true); // for event
|
||||
bool IsVendorItemValid(uint32 vendor_entry, uint32 item, int32 maxcount, uint32 ptime, int32 ExtendedCost, Player* pl = NULL, std::set<uint32>* skip_vendors = NULL, uint32 ORnpcflag = 0) const;
|
||||
void AddVendorItem(uint32 entry,uint32 item, int32 maxcount, uint32 incrtime, uint32 ExtendedCost, bool savetodb = true); // for event
|
||||
bool RemoveVendorItem(uint32 entry, uint32 item, bool savetodb = true); // for event
|
||||
bool IsVendorItemValid(uint32 vendor_entry, uint32 item, int32 maxcount, uint32 ptime, uint32 ExtendedCost, Player* pl = NULL, std::set<uint32>* skip_vendors = NULL, uint32 ORnpcflag = 0) const;
|
||||
|
||||
void LoadScriptNames();
|
||||
ScriptNameMap &GetScriptNames() { return m_scriptNames; }
|
||||
|
||||
@@ -772,7 +772,7 @@ void WorldSession::SendListInventory(uint64 vendorguid)
|
||||
++count;
|
||||
|
||||
// reputation discount
|
||||
int32 price = crItem->IsExcludeMoneyPrice() ? 0 : uint32(floor(pProto->BuyPrice * discountMod));
|
||||
int32 price = crItem->IsGoldRequired(pProto) ? uint32(floor(pProto->BuyPrice * discountMod)) : 0;
|
||||
|
||||
data << uint32(vendorslot+1); // client expects counting to start at 1
|
||||
data << uint32(crItem->item);
|
||||
@@ -781,7 +781,7 @@ void WorldSession::SendListInventory(uint64 vendorguid)
|
||||
data << uint32(price);
|
||||
data << uint32(pProto->MaxDurability);
|
||||
data << uint32(pProto->BuyCount);
|
||||
data << uint32(crItem->GetExtendedCostId());
|
||||
data << uint32(crItem->ExtendedCost);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user