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:
@@ -7954,7 +7954,7 @@ int ObjectMgr::LoadReferenceVendor(int32 vendor, int32 item, std::set<uint32> *s
|
||||
{
|
||||
int32 maxcount = fields[1].GetInt32();
|
||||
uint32 incrtime = fields[2].GetUInt32();
|
||||
uint32 ExtendedCost = fields[3].GetUInt32();
|
||||
int32 ExtendedCost = fields[3].GetUInt32();
|
||||
|
||||
if (!IsVendorItemValid(vendor,item_id,maxcount,incrtime,ExtendedCost,NULL,skip_vendors))
|
||||
continue;
|
||||
@@ -8009,7 +8009,7 @@ void ObjectMgr::LoadVendors()
|
||||
{
|
||||
int32 maxcount = fields[2].GetInt32();
|
||||
uint32 incrtime = fields[3].GetUInt32();
|
||||
uint32 ExtendedCost = fields[4].GetUInt32();
|
||||
int32 ExtendedCost = fields[4].GetUInt32();
|
||||
|
||||
if (!IsVendorItemValid(entry,item_id,maxcount,incrtime,ExtendedCost,NULL,&skip_vendors))
|
||||
continue;
|
||||
@@ -8223,12 +8223,12 @@ void ObjectMgr::LoadGossipMenuItems()
|
||||
sLog.outString(">> Loaded %u gossip_menu_option entries", count);
|
||||
}
|
||||
|
||||
void ObjectMgr::AddVendorItem(uint32 entry,uint32 item, int32 maxcount, uint32 incrtime, uint32 extendedcost, bool savetodb)
|
||||
void ObjectMgr::AddVendorItem(uint32 entry,uint32 item, int32 maxcount, uint32 incrtime, int32 extendedcost, bool savetodb)
|
||||
{
|
||||
VendorItemData& vList = m_mCacheVendorItemMap[entry];
|
||||
vList.AddItem(item,maxcount,incrtime,extendedcost);
|
||||
|
||||
if (savetodb) WorldDatabase.PExecuteLog("INSERT INTO npc_vendor (entry,item,maxcount,incrtime,extendedcost) VALUES('%u','%u','%u','%u','%u')",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)
|
||||
@@ -8244,7 +8244,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, uint32 ExtendedCost, Player* pl, std::set<uint32>* skip_vendors, uint32 ORnpcflag) const
|
||||
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
|
||||
{
|
||||
CreatureInfo const* cInfo = GetCreatureTemplate(vendor_entry);
|
||||
if (!cInfo)
|
||||
@@ -8280,12 +8280,13 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ExtendedCost && !sItemExtendedCostStore.LookupEntry(ExtendedCost))
|
||||
uint32 extendedCostId = std::abs(ExtendedCost);
|
||||
if (extendedCostId && !sItemExtendedCostStore.LookupEntry(extendedCostId))
|
||||
{
|
||||
if (pl)
|
||||
ChatHandler(pl).PSendSysMessage(LANG_EXTENDED_COST_NOT_EXIST,ExtendedCost);
|
||||
ChatHandler(pl).PSendSysMessage(LANG_EXTENDED_COST_NOT_EXIST,extendedCostId);
|
||||
else
|
||||
sLog.outErrorDb("Table `(game_event_)npc_vendor` have Item (Entry: %u) with wrong ExtendedCost (%u) for vendor (%u), ignore",item_id,ExtendedCost,vendor_entry);
|
||||
sLog.outErrorDb("Table `(game_event_)npc_vendor` have Item (Entry: %u) with wrong ExtendedCost (%u) for vendor (%u), ignore",item_id,extendedCostId,vendor_entry);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -8310,12 +8311,12 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max
|
||||
if (!vItems)
|
||||
return true; // later checks for non-empty lists
|
||||
|
||||
if(vItems->FindItemCostPair(item_id,ExtendedCost))
|
||||
if(vItems->FindItemCostPair(item_id,extendedCostId))
|
||||
{
|
||||
if (pl)
|
||||
ChatHandler(pl).PSendSysMessage(LANG_ITEM_ALREADY_IN_LIST, item_id, ExtendedCost);
|
||||
ChatHandler(pl).PSendSysMessage(LANG_ITEM_ALREADY_IN_LIST, item_id, extendedCostId);
|
||||
else
|
||||
sLog.outErrorDb( "Table `npc_vendor` has duplicate items %u (with extended cost %u) for vendor (Entry: %u), ignoring", item_id, ExtendedCost, vendor_entry);
|
||||
sLog.outErrorDb( "Table `npc_vendor` has duplicate items %u (with extended cost %u) for vendor (Entry: %u), ignoring", item_id, extendedCostId, vendor_entry);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -874,9 +874,9 @@ class ObjectMgr
|
||||
|
||||
return &iter->second;
|
||||
}
|
||||
void AddVendorItem(uint32 entry,uint32 item, int32 maxcount, uint32 incrtime, uint32 ExtendedCost, bool savetodb = true); // for event
|
||||
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, uint32 ExtendedCost, Player* pl = NULL, std::set<uint32>* skip_vendors = NULL, uint32 ORnpcflag = 0) const;
|
||||
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 LoadScriptNames();
|
||||
ScriptNameMap &GetScriptNames() { return m_scriptNames; }
|
||||
|
||||
Reference in New Issue
Block a user