EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Support::Windows Servers (https://www.eqemulator.org/forums/forumdisplay.php?f=587)
-   -   Merchants not returning proper amount (https://www.eqemulator.org/forums/showthread.php?t=35838)

lerxst2112 10-13-2012 07:53 PM

Quote:

Originally Posted by Uleat (Post 213299)
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.

Floating point to integer conversion is defined by the C++ standard and not open to interpretation by different compiler vendors. The whole number is kept and the fraction discarded. 1.01 and 1.99 both become 1.

Looking at the database log it exactly matches what the vendor said he'd give you in all cases, and that is the amount sent to the AddMoneyToPP function.

Look in the debug zone log and see if you see the money being logged. The line would start with "Client::AddMoneyToPP()" and the values would show what the server believes your character has which should agree with the client unless there's something wrong when sending it.

I didn't see a # command that would list your money so it would seem like that log is the only way you'll easily be able to tell if what you actually have on the server is the same as what the client is showing you.

Traul 10-13-2012 08:00 PM

Quote:

Originally Posted by lerxst2112 (Post 213300)
Floating point to integer conversion is defined by the C++ standard and not open to interpretation by different compiler vendors. The whole number is kept and the fraction discarded. 1.01 and 1.99 both become 1.

Looking at the database log it exactly matches what the vendor said he'd give you in all cases, and that is the amount sent to the AddMoneyToPP function.

Look in the debug zone log and see if you see the money being logged. The line would start with "Client::AddMoneyToPP()" and the values would show what the server believes your character has which should agree with the client unless there's something wrong when sending it.

I didn't see a # command that would list your money so it would seem like that log is the only way you'll easily be able to tell if what you actually have on the server is the same as what the client is showing you.

Here's the log from zone.exe:

Quote:

[10.13. - 16:15:17] [CLIENT__NET_ERR] Nalia: Unhandled incoming opcode: [OpCode OP_WeaponEquip2 (0x63da) Size=8]
[10.13. - 16:15:17] [CLIENT__NET_ERR] Nalia: Unhandled incoming opcode: [OpCode OP_WeaponEquip2 (0x63da) Size=8]
[10.13. - 16:15:17] [CLIENT__NET_ERR] Nalia: Unhandled incoming opcode: [OpCode OP_WeaponEquip1 (0x6c5e) Size=12]
[10.13. - 16:17:36] Client::AddMoneyToPP() Nalia should have: plat:72 gold:2 silver:2 copper:2
[10.13. - 16:17:36] DeleteItemInInventory(28, 1, false)
[10.13. - 16:17:59] Client::AddMoneyToPP() Nalia should have: plat:1372 gold:1 silver:8 copper:8
[10.13. - 16:17:59] DeleteItemInInventory(28, 19, false)
[10.13. - 16:18:27] Nalia, purchase item..
[10.13. - 16:18:27] [INVENTORY__SLOTS] Nalia: Putting item Whip Pattern (16479) into slot 28
[10.13. - 16:18:45] Client::AddMoneyToPP() Nalia should have: plat:3 gold:1 silver:0 copper:0
[10.13. - 16:18:45] DeleteItemInInventory(28, 1, false)
So this agrees what it's actually sending me, but disagrees with what the merchant and database log says.

By the way, thanks for taking a look at this guys, I appreciate it :)

lerxst2112 10-14-2012 02:37 AM

Well, the answer is that Client::AddMoneyToPP() has a bug in it. It's hard to see because it's hideously formatted and a bizarre way to split the digits up, but whatever.

Code:

Index: client.cpp
===================================================================
--- client.cpp        (revision 2230)
+++ client.cpp        (working copy)
@@ -2154,6 +2154,7 @@
        //tmp        = tmp - (tmp2* 10);
    //if (updateclient)
        //        SendClientMoneyUpdate(0,tmp);
+        tmp2 = tmp;
    new_val = m_pp.copper + tmp2;
    if(new_val < 0) {
        m_pp.copper = 0;

The copper value was never assigned to tmp2 (nice variables names!) so it stayed whatever the silver value was.

If I were the truly ambitious sort I'd replace that entire function with something like this:

Code:

void Client::AddMoneyToPP(uint64 copper, bool updateclient) {
        sint32 platinum = copper / 1000;
        sint32 gold = (copper / 100) % 10;
        sint32 silver = (copper / 10) % 10;
        copper %= 10;
        AddMoneyToPP( copper, silver, gold, platinum, updateclient );
}


Traul 10-14-2012 03:02 PM

Awesome, all fixed. Thanks for the help!

Uleat 10-14-2012 05:33 PM

Damn..He beat me to it! Lol!


All times are GMT -4. The time now is 11:01 PM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.