Core/Items: Fix item sell price not scaling with item level

Port From (https://github.com/TrinityCore/TrinityCore/commit/500301b96256792357b13ef78d7e1836028cff26)
This commit is contained in:
Hondacrx
2024-08-24 21:14:30 -04:00
parent c3e4f234b6
commit 29aecf864e
3 changed files with 45 additions and 46 deletions
+1 -1
View File
@@ -1754,7 +1754,7 @@ namespace Game.Entities
typeFactor = weaponPrice.Data; typeFactor = weaponPrice.Data;
} }
standardPrice = false; standardPrice = true;
return (uint)(proto.GetPriceVariance() * typeFactor * baseFactor * qualityFactor * proto.GetPriceRandomValue()); return (uint)(proto.GetPriceVariance() * typeFactor * baseFactor * qualityFactor * proto.GetPriceRandomValue());
} }
+1 -5
View File
@@ -3039,11 +3039,7 @@ namespace Game.Entities
uint eslot = slot - InventorySlots.BuyBackStart; uint eslot = slot - InventorySlots.BuyBackStart;
SetInvSlot(slot, pItem.GetGUID()); SetInvSlot(slot, pItem.GetGUID());
ItemTemplate proto = pItem.GetTemplate(); SetBuybackPrice(eslot, pItem.GetSellPrice(this) * pItem.GetCount());
if (proto != null)
SetBuybackPrice(eslot, proto.GetSellPrice() * pItem.GetCount());
else
SetBuybackPrice(eslot, 0);
SetBuybackTimestamp(eslot, etime); SetBuybackTimestamp(eslot, etime);
+9 -6
View File
@@ -429,12 +429,16 @@ namespace Game
} }
} }
ItemTemplate pProto = pItem.GetTemplate(); uint sellPrice = pItem.GetSellPrice(_player);
if (pProto != null) if (sellPrice > 0)
{ {
if (pProto.GetSellPrice() > 0) ulong money = sellPrice * packet.Amount;
if (money > uint.MaxValue) // ensure sell price * amount doesn't overflow buyback price
{ {
ulong money = pProto.GetSellPrice() * packet.Amount; _player.SendSellError(SellResult.CantSellItem, creature, packet.ItemGUID);
return;
}
if (!_player.ModifyMoney((long)money)) // ensure player doesn't exceed gold limit if (!_player.ModifyMoney((long)money)) // ensure player doesn't exceed gold limit
{ {
@@ -477,8 +481,7 @@ namespace Game
pl.SendSellError(SellResult.CantSellItem, creature, packet.ItemGUID); pl.SendSellError(SellResult.CantSellItem, creature, packet.ItemGUID);
return; return;
} }
} pl.SendSellError(SellResult.CantFindItem, creature, packet.ItemGUID);
pl.SendSellError(SellResult.CantSellItem, creature, packet.ItemGUID);
return; return;
} }