Merchants not returning proper amount
So something I noticed recently on my server, the merchants aren't returning the correct amount of money when you sell something to them. This only seems to happen with the lower denominations of currency (copper, silver).
For example, I have several items on my server that are supposed to sell for 1-4 copper pieces, and the merchant says they will buy it for this amount, yet when you sell it to them you do not receive any copper. Other times when you sell something for, let's say, 14 platinum, 5 gold, 4 silver, 2 copper you'll recieve 14 platinum, 5 gold, 4 silver, 9 copper Any idea what could be going on here? |
What revision, build, etc.
|
Maybe an underlying issue with charisma factoring into price AFTER the exchange has happened?
|
My code is all up to date, and yeah I also thought the whole charisma mod might have something to do with it, but I set the rules to false but nothing changed. Also, having charisma of 85 or 255 didn't affect it at all either.
|
Does anyone know where I can find the code that sends the money to the client after the client sells to an item to a merchant?
|
Client::Handle_OP_ShopPlayerSell which calls Client::AddMoneyToPP.
|
Quote:
I did however do some more testing, and I figured out what's going on. I'm always given the proper amounts of platinum, gold, and silver that the merchant tells me, but it's using the silver amount for the amount of copper to give me as well. For example: A merchant says it'll give me 4pp, 3gp, 2sp, 1cp for an item What I'll actually receive is 4pp, 3gp, 2sp, 2cp (I realize now that my example in the OP doesn't match this and is incorrect, I was just making it up from what I thought I remembered) This also explains why I'd get absolutely nothing when I sold an item that sold for less than 1 silver piece: the amount of silver pieces returned would be 0 and therefore copper pieces would also be 0. I have absolutely no idea how to go about fixing this though, and was really hoping someone would have an idea. This is on a titanium client so is it possible something is going wrong in the opcodes? Or could this be a longstanding bug that no one's really noticed because nobody really pays much attention to their lousy copper pieces? ;) |
Well, being off by 1 copper might happen due to rounding up. According to the code comments though it should match the client display.
So, some questions... Can you give some examples of the item IDs you are selling that are giving the incorrect amount? It would need to be things you haven't modified the price on so someone else could test it and see what happens. What are the rules UsePriceMod and BuyCostMod set to in your database? Is your server 32 or 64 bit? |
I remember this conversation between Kimmy and CD a while ago. I believe they were talking about a rounding issue. I'll have to go back and see if I can find where it was at.
|
Code:
if (RuleB(Merchant, UsePriceMod)){ |
You might also want to perform the transaction and then camp out and relog after annotating your current money values.
That will resync the client to the server amount and give a better idea as to whether it's a server or client issue. |
Relogging doesn't change anything for me. And I really don't think it's a rounding issue, it always gives me the same amount of silver in copper even if it's off by 1. Here's some screenshots to illustrate:
Here I'm about to sell a diamond for the listed price, notice it will give me 2 silver, but 0 copper: http://i.imgur.com/78O9B.jpg And now I sell 1 of them and look, I get the 2 copper instead of none: http://i.imgur.com/h8KdF.jpg Now I'll sell all 19 of them (I deleted all my money first) and again, I'm given same amount of copper as silver when I should be getting 0 copper: http://i.imgur.com/ssQKj.jpg http://i.imgur.com/u5Chy.jpg (split post due to 4 image limit) |
This only happens when selling though, buying still works perfectly fine. Here I'll buy the whip pattern and it will remove 5 copper from me just like it says it should:
http://i.imgur.com/A6thy.jpg http://i.imgur.com/LcMKE.jpg Now I'll sell the whip pattern back. Since I won't be getting any silver back for it, we can predict I won't be getting any copper either (even though I should get 5), and sure enough... http://i.imgur.com/ZCgva.jpg http://i.imgur.com/GJoya.jpg The server is 32bit, and I've gone and logged onto other servers and sold items just fine so I don't think it's a client issue. I have the price mod turned off and buycostmod and sellcostmod both set to 1.00 for testing purposes. This really has me stumped. |
Quote:
http://i.imgur.com/kiO8h.jpg |
That definitely clarifed the point for anyone who didn't get it.
The only thing I can think of would be a possible difference in the way that MS uses conversions over Linux..assuming the servers that you logged into were different than yours. (I'll try tonight on my win server and see what happens.) When forcing a conversion from float to int, doesn't the rounding function automatically ignore and drop the fractional amount regardless? I know 'Excel' does and you have to use special functions to roundup..but even that implementation changed between versions. |
All times are GMT -4. The time now is 11:18 PM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.