[Fix] Parcel Delivery Updates (#4688)

* Fix two parcel bugs

Fix two Parcel Bugs

- If a player was at their parcel limit and perform a bazaar purchase via parcel delivery, their money would be lost
- If a container with items was delivered via parcel, the parcel under certain inventory conditions could be delivered into an incorrect slot resulting in the container being lost.

* Incorrect field used for BagSize vs ItemSize.  Silly mistake.

* Remove duplicate check and reorder stacking check

* Fix edge case when Parcel Window remains open and Bazaar purchases are made.

* Repair
- bazaar purchase of items with charges reverting to 1 charge in error
- bazaar visual error with selling price. Was caused by the parcel fee not being properly reflected in the client
- corrected a type mismatch with parcel fee uint32 vs uin64
- corrected a few TraderPurchase and TraderSell event data points by splitting quantity and charges

* Formatting

* Use pre-existing AddMoney and TakeMoney and remove unnecessary routines

* Updates after rebase
This commit is contained in:
Mitch Freeman
2025-02-15 20:27:09 -04:00
committed by GitHub
parent c09fad5a75
commit ab4e1191ef
8 changed files with 210 additions and 277 deletions
-101
View File
@@ -12969,107 +12969,6 @@ void Client::RemoveItemBySerialNumber(uint32 serial_number, uint32 quantity)
}
}
void Client::AddMoneyToPPWithOverflow(uint64 copper, bool update_client)
{
//I noticed in the ROF2 client that the client auto updates the currency values using overflow
//Therefore, I created this method to ensure that the db matches and clients don't see 10 pp 5 gp
//becoming 9pp 15 gold with the current AddMoneyToPP method.
auto add_pp = copper / 1000;
auto add_gp = (copper - add_pp * 1000) / 100;
auto add_sp = (copper - add_pp * 1000 - add_gp * 100) / 10;
auto add_cp = copper - add_pp * 1000 - add_gp * 100 - add_sp * 10;
m_pp.copper += add_cp;
if (m_pp.copper >= 10) {
m_pp.silver += m_pp.copper / 10;
m_pp.copper = m_pp.copper % 10;
}
m_pp.silver += add_sp;
if (m_pp.silver >= 10) {
m_pp.gold += m_pp.silver / 10;
m_pp.silver = m_pp.silver % 10;
}
m_pp.gold += add_gp;
if (m_pp.gold >= 10) {
m_pp.platinum += m_pp.gold / 10;
m_pp.gold = m_pp.gold % 10;
}
m_pp.platinum += add_pp;
if (update_client) {
SendMoneyUpdate();
}
RecalcWeight();
SaveCurrency();
LogDebug("Client::AddMoneyToPPWithOverflow() [{}] should have: plat:[{}] gold:[{}] silver:[{}] copper:[{}]",
GetName(),
m_pp.platinum,
m_pp.gold,
m_pp.silver,
m_pp.copper
);
}
bool Client::TakeMoneyFromPPWithOverFlow(uint64 copper, bool update_client)
{
int32 remove_pp = copper / 1000;
int32 remove_gp = (copper - remove_pp * 1000) / 100;
int32 remove_sp = (copper - remove_pp * 1000 - remove_gp * 100) / 10;
int32 remove_cp = copper - remove_pp * 1000 - remove_gp * 100 - remove_sp * 10;
uint64 current_money = GetCarriedMoney();
if (copper > current_money) {
return false; //client does not have enough money on them
}
m_pp.copper -= remove_cp;
if (m_pp.copper < 0) {
m_pp.silver -= 1;
m_pp.copper = m_pp.copper + 10;
if (m_pp.copper >= 10) {
m_pp.silver += m_pp.copper / 10;
m_pp.copper = m_pp.copper % 10;
}
}
m_pp.silver -= remove_sp;
if (m_pp.silver < 0) {
m_pp.gold -= 1;
m_pp.silver = m_pp.silver + 10;
if (m_pp.silver >= 10) {
m_pp.gold += m_pp.silver / 10;
m_pp.silver = m_pp.silver % 10;
}
}
m_pp.gold -= remove_gp;
if (m_pp.gold < 0) {
m_pp.platinum -= 1;
m_pp.gold = m_pp.gold + 10;
if (m_pp.gold >= 10) {
m_pp.platinum += m_pp.gold / 10;
m_pp.gold = m_pp.gold % 10;
}
}
m_pp.platinum -= remove_pp;
if (update_client) {
SendMoneyUpdate();
}
SaveCurrency();
RecalcWeight();
return true;
}
void Client::SendTopLevelInventory()
{
EQ::ItemInstance* inst = nullptr;