Merge pull request #1528 from noudess/merchant

Fix bug where stacks of non-stackable items are removed when you buy 1.
This commit is contained in:
Paul Coene 2021-09-11 10:19:37 -04:00 committed by GitHub
commit b6ba493450
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -361,7 +361,8 @@ void Zone::DumpMerchantList(uint32 npcid) {
int Zone::SaveTempItem(uint32 merchantid, uint32 npcid, uint32 item, int32 charges, bool sold) { int Zone::SaveTempItem(uint32 merchantid, uint32 npcid, uint32 item, int32 charges, bool sold) {
LogInventory("Transaction of [{}] [{}]", charges, item); LogInventory("[{}] [{}] charges of [{}]", ((sold) ? "Sold" : "Bought"),
charges, item);
//DumpMerchantList(npcid); //DumpMerchantList(npcid);
// Iterate past main items. // Iterate past main items.
// If the item being transacted is in this list, return 0; // If the item being transacted is in this list, return 0;
@ -419,8 +420,7 @@ int Zone::SaveTempItem(uint32 merchantid, uint32 npcid, uint32 item, int32 charg
if (!ml.origslot) { if (!ml.origslot) {
ml.origslot = ml.slot; ml.origslot = ml.slot;
} }
bool is_stackable = database.GetItem(item)->Stackable; if (ml.charges > 0) {
if ((is_stackable && charges > 0) || (!is_stackable && sold)) {
database.SaveMerchantTemp(npcid, ml.origslot, item, ml.charges); database.SaveMerchantTemp(npcid, ml.origslot, item, ml.charges);
tmp_merlist.push_back(ml); tmp_merlist.push_back(ml);
} else { } else {