Go Back   EQEmulator Home > EQEmulator Forums > Support > Support::Windows Servers

Support::Windows Servers Support forum for Windows EQEMu users.

Reply
 
Thread Tools Display Modes
  #1  
Old 10-07-2012, 06:02 PM
Traul
Hill Giant
 
Join Date: Jun 2005
Posts: 105
Default 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?
Reply With Quote
  #2  
Old 10-07-2012, 06:32 PM
sorvani
Dragon
 
Join Date: May 2010
Posts: 965
Default

What revision, build, etc.
Reply With Quote
  #3  
Old 10-07-2012, 07:55 PM
chrsschb's Avatar
chrsschb
Dragon
 
Join Date: Nov 2008
Location: GA
Posts: 904
Default

Maybe an underlying issue with charisma factoring into price AFTER the exchange has happened?
__________________
Clumsy's World: Resurgence [2019-Present]
Clumsy's World 2.0 [2014-2016]
Clumsy's World [2006-2012]
Reply With Quote
  #4  
Old 10-08-2012, 02:09 PM
Traul
Hill Giant
 
Join Date: Jun 2005
Posts: 105
Default

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.
Reply With Quote
  #5  
Old 10-12-2012, 06:03 PM
Traul
Hill Giant
 
Join Date: Jun 2005
Posts: 105
Default

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?
Reply With Quote
  #6  
Old 10-12-2012, 08:46 PM
lerxst2112
Demi-God
 
Join Date: Aug 2010
Posts: 1,742
Default

Client::Handle_OP_ShopPlayerSell which calls Client::AddMoneyToPP.
Reply With Quote
  #7  
Old 10-13-2012, 12:07 AM
Traul
Hill Giant
 
Join Date: Jun 2005
Posts: 105
Default

Quote:
Originally Posted by lerxst2112 View Post
Client::Handle_OP_ShopPlayerSell which calls Client::AddMoneyToPP.
Thanks, I took a look at the code and it's definitely beyond my very limited C++ skills.

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?
Reply With Quote
  #8  
Old 10-13-2012, 12:37 AM
lerxst2112
Demi-God
 
Join Date: Aug 2010
Posts: 1,742
Default

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?
Reply With Quote
  #9  
Old 10-13-2012, 06:34 AM
joligario's Avatar
joligario
Developer
 
Join Date: Mar 2003
Posts: 1,497
Default

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.
Reply With Quote
  #10  
Old 10-13-2012, 11:52 AM
lerxst2112
Demi-God
 
Join Date: Aug 2010
Posts: 1,742
Default

Code:
	if (RuleB(Merchant, UsePriceMod)){
	price=(int)((item->Price*mp->quantity)*(RuleR(Merchant, BuyCostMod))*Client::CalcPriceMod(vendor,true)+0.5); // need to round up, because client does it automatically when displaying price
	}
	else
		price=(int)((item->Price*mp->quantity)*(RuleR(Merchant, BuyCostMod))+0.5);
	AddMoneyToPP(price,false);
At a quick glance, this math looks ok to me. Probably worth setting the EventLog:RecordSellToMerchant rule to true to see what is actually being calculated. With some concrete example items it should be easy enough to see if there's an issue with specific values.
Reply With Quote
  #11  
Old 10-13-2012, 06:42 PM
Traul
Hill Giant
 
Join Date: Jun 2005
Posts: 105
Default

Quote:
Originally Posted by lerxst2112 View Post
Code:
	if (RuleB(Merchant, UsePriceMod)){
	price=(int)((item->Price*mp->quantity)*(RuleR(Merchant, BuyCostMod))*Client::CalcPriceMod(vendor,true)+0.5); // need to round up, because client does it automatically when displaying price
	}
	else
		price=(int)((item->Price*mp->quantity)*(RuleR(Merchant, BuyCostMod))+0.5);
	AddMoneyToPP(price,false);
At a quick glance, this math looks ok to me. Probably worth setting the EventLog:RecordSellToMerchant rule to true to see what is actually being calculated. With some concrete example items it should be easy enough to see if there's an issue with specific values.
Here's the log of above the transactions:

Reply With Quote
  #12  
Old 10-13-2012, 04:43 PM
Uleat's Avatar
Uleat
Developer
 
Join Date: Apr 2012
Location: North Carolina
Posts: 2,815
Default

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.
__________________
Uleat of Bertoxxulous

Compilin' Dirty
Reply With Quote
  #13  
Old 10-13-2012, 06:36 PM
Traul
Hill Giant
 
Join Date: Jun 2005
Posts: 105
Default

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:



And now I sell 1 of them and look, I get the 2 copper instead of none:



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:





(split post due to 4 image limit)
Reply With Quote
  #14  
Old 10-13-2012, 06:36 PM
Traul
Hill Giant
 
Join Date: Jun 2005
Posts: 105
Default

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:




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...





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.
Reply With Quote
  #15  
Old 10-13-2012, 07:28 PM
Uleat's Avatar
Uleat
Developer
 
Join Date: Apr 2012
Location: North Carolina
Posts: 2,815
Default

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.
__________________
Uleat of Bertoxxulous

Compilin' Dirty
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 09:14 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3