aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/updates/8568_world_npc_vendor.sql1
-rw-r--r--sql/updates/8568_world_trinity_string.sql4
-rw-r--r--src/server/game/Chat/Commands/Level2.cpp2
-rw-r--r--src/server/game/Entities/Creature/Creature.cpp2
-rw-r--r--src/server/game/Entities/Creature/Creature.h12
-rw-r--r--src/server/game/Entities/Player/Player.cpp27
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp23
-rw-r--r--src/server/game/Globals/ObjectMgr.h4
-rw-r--r--src/server/game/Server/Protocol/Handlers/ItemHandler.cpp4
9 files changed, 45 insertions, 34 deletions
diff --git a/sql/updates/8568_world_npc_vendor.sql b/sql/updates/8568_world_npc_vendor.sql
new file mode 100644
index 00000000000..63645847ef6
--- /dev/null
+++ b/sql/updates/8568_world_npc_vendor.sql
@@ -0,0 +1 @@
+ALTER TABLE npc_vendor CHANGE COLUMN `ExtendedCost` `ExtendedCost` mediumint(8) NOT NULL default '0' COMMENT 'negative if cost must exclude normal money cost';
diff --git a/sql/updates/8568_world_trinity_string.sql b/sql/updates/8568_world_trinity_string.sql
new file mode 100644
index 00000000000..029966a4968
--- /dev/null
+++ b/sql/updates/8568_world_trinity_string.sql
@@ -0,0 +1,4 @@
+DELETE FROM trinity_string WHERE entry IN (210);
+INSERT INTO trinity_string VALUES
+(210,'Item \'%i\' (with extended cost %i) already in vendor list.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
+
diff --git a/src/server/game/Chat/Commands/Level2.cpp b/src/server/game/Chat/Commands/Level2.cpp
index 40772a82922..85c5ef739fd 100644
--- a/src/server/game/Chat/Commands/Level2.cpp
+++ b/src/server/game/Chat/Commands/Level2.cpp
@@ -1051,7 +1051,7 @@ bool ChatHandler::HandleNpcAddVendorItemCommand(const char* args)
incrtime = atol(fincrtime);
char* fextendedcost = strtok(NULL, " "); //add ExtendedCost, default: 0
- uint32 extendedcost = fextendedcost ? atol(fextendedcost) : 0;
+ int32 extendedcost = fextendedcost ? atol(fextendedcost) : 0;
Creature* vendor = getSelectedCreature();
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index 71461f94949..c9c9775c04a 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -76,7 +76,7 @@ bool VendorItemData::RemoveItem(uint32 item_id)
return found;
}
-VendorItem const* VendorItemData::FindItemCostPair(uint32 item_id, uint32 extendedCost) const
+VendorItem const* VendorItemData::FindItemCostPair(uint32 item_id, int32 extendedCost) const
{
for (VendorItemList::const_iterator i = m_items.begin(); i != m_items.end(); ++i)
if((*i)->item == item_id && (*i)->ExtendedCost == extendedCost)
diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h
index c19187f2770..a7c17561516 100644
--- a/src/server/game/Entities/Creature/Creature.h
+++ b/src/server/game/Entities/Creature/Creature.h
@@ -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)
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index c79ce17f40e..faeb676c21a 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -19573,12 +19573,12 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32
return false;
}
- if (crItem->ExtendedCost)
+ if (uint32 extendedCostId = crItem->GetExtendedCostId())
{
- ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost);
+ ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(extendedCostId);
if (!iece)
{
- sLog.outError("Item %u have wrong ExtendedCost field value %u", pProto->ItemId, crItem->ExtendedCost);
+ sLog.outError("Item %u have wrong ExtendedCost field value %u", pProto->ItemId, extendedCostId);
return false;
}
@@ -19615,10 +19615,11 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32
}
}
- int32 price = pProto->BuyPrice * count;
+ int32 price = crItem->IsExcludeMoneyPrice() ? 0 : pProto->BuyPrice * count;
// reputation discount
- price = uint32(floor(price * GetReputationPriceDiscount(pCreature)));
+ if (price)
+ price = uint32(floor(price * GetReputationPriceDiscount(pCreature)));
if (GetMoney() < price)
{
@@ -19638,9 +19639,9 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32
ModifyMoney(-(int32)price);
- if (crItem->ExtendedCost) // case for new honor system
+ if (uint32 extendedCostId = crItem->GetExtendedCostId()) // case for new honor system
{
- ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost);
+ ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(extendedCostId);
if (iece->reqhonorpoints)
ModifyHonorPoints(- int32(iece->reqhonorpoints * count));
@@ -19666,11 +19667,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->ExtendedCost)
+ if (it->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_REFUNDABLE) && crItem->GetExtendedCostId())
{
it->SetRefundRecipient(GetGUIDLow());
it->SetPaidMoney(price);
- it->SetPaidExtendedCost(crItem->ExtendedCost);
+ it->SetPaidExtendedCost(crItem->GetExtendedCostId());
it->SaveRefundDataToDB();
AddRefundReference(it->GetGUID());
}
@@ -19693,9 +19694,9 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32
}
ModifyMoney(-(int32)price);
- if (crItem->ExtendedCost) // case for new honor system
+ if (uint32 extendedCostId = crItem->GetExtendedCostId()) // case for new honor system
{
- ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost);
+ ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(extendedCostId);
if (iece->reqhonorpoints)
ModifyHonorPoints(- int32(iece->reqhonorpoints * count));
@@ -19724,11 +19725,11 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32
AutoUnequipOffhandIfNeed();
- if (it->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_REFUNDABLE) && crItem->ExtendedCost)
+ if (it->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_REFUNDABLE) && crItem->GetExtendedCostId())
{
it->SetRefundRecipient(GetGUIDLow());
it->SetPaidMoney(price);
- it->SetPaidExtendedCost(crItem->ExtendedCost);
+ it->SetPaidExtendedCost(crItem->GetExtendedCostId());
it->SaveRefundDataToDB();
AddRefundReference(it->GetGUID());
}
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 5f460c7e84c..8b3cf97a3fe 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -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;
}
diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h
index c1471aa0680..eeeb871c98e 100644
--- a/src/server/game/Globals/ObjectMgr.h
+++ b/src/server/game/Globals/ObjectMgr.h
@@ -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; }
diff --git a/src/server/game/Server/Protocol/Handlers/ItemHandler.cpp b/src/server/game/Server/Protocol/Handlers/ItemHandler.cpp
index 53aede43492..897ee7dcfd3 100644
--- a/src/server/game/Server/Protocol/Handlers/ItemHandler.cpp
+++ b/src/server/game/Server/Protocol/Handlers/ItemHandler.cpp
@@ -766,7 +766,7 @@ void WorldSession::SendListInventory(uint64 vendorguid)
++count;
// reputation discount
- int32 price = uint32(floor(pProto->BuyPrice * discountMod));
+ int32 price = crItem->IsExcludeMoneyPrice() ? 0 : uint32(floor(pProto->BuyPrice * discountMod));
data << uint32(vendorslot+1); // client expects counting to start at 1
data << uint32(crItem->item);
@@ -775,7 +775,7 @@ void WorldSession::SendListInventory(uint64 vendorguid)
data << uint32(price);
data << uint32(pProto->MaxDurability);
data << uint32(pProto->BuyCount);
- data << uint32(crItem->ExtendedCost);
+ data << uint32(crItem->GetExtendedCostId());
}
}
}