PDA

View Full Version : COMMITTED: Prices when buying stacks


Leere
03-07-2010, 09:58 AM
zone\client_packet.cpp (rev 1276)
@@ -4936,11 +4936,13 @@
}
}

+ int singleprice = 0;
if (RuleB(Merchant, UsePriceMod)){
- mpo->price = (item->Price*(RuleR(Merchant, SellCostMod))*item->SellRate*Client::CalcPriceMod(tmp,false))*mp->quantity;
+ singleprice = (item->Price*(RuleR(Merchant, SellCostMod))*item->SellRate*Client::CalcPriceMod(tmp,false));
}
else
- mpo->price = (item->Price*(RuleR(Merchant, SellCostMod))*item->SellRate)*mp->quantity;
+ singleprice = (item->Price*(RuleR(Merchant, SellCostMod))*item->SellRate);
+ mpo->price = singleprice*mp->quantity;
if(freeslotid == SLOT_INVALID || (mpo->price < 0 ) || !TakeMoneyFromPP(mpo->price))
{
safe_delete(outapp);
@@ -4976,7 +4978,7 @@
else {
// Update the charges/quantity in the merchant window
inst->SetCharges(new_charges);
- inst->SetPrice(mpo->price);
+ inst->SetPrice(singleprice);
inst->SetMerchantSlot(mp->itemslot);
inst->SetMerchantCount(new_charges);




This addresses two issues. The first is how the client displays the wrong price for items from the temporary item list when not all of them were bought within one transaction. PEQ (link) (http://www.projecteq.net/phpBB2/viewtopic.php?t=8363) has two reports of that issue.

The second issue is more of a side benefit of the first fix, it fixes the part where buying a stack of items leads to a price that is not equal to the displayed price times the quantity. (For example, buying a flask of water. Displayed price of 1 silver. Buying a stack of 20 them then leads to a price of 2g 3c, instead of the expected 2g.)

Derision
03-07-2010, 10:41 AM
I saw the post on PEQ and put in a fix before I saw your post :)

I'll update it with your refinement to calculate the singleprice once (it did occur to me to do that, but I was being lazy and didn't realize it would fix the other issue you mention).