EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Support::Windows Servers (https://www.eqemulator.org/forums/forumdisplay.php?f=587)
-   -   I need to fix this folks (https://www.eqemulator.org/forums/showthread.php?t=36606)

lerxst2112 03-04-2013 10:58 PM

Quote:

Originally Posted by Uleat (Post 219238)
Do we need to change this to double from float and add a con check for '(base*mod) > ~0'?

Why? There shouldn't be an issue with range or precision using a float.

Uleat 03-05-2013 12:11 AM

Nope, you're right...

x = 3000000000, y = 3E+09, z = 3000000000

x as uint32 = 3,000,000,000
y as single = x
z as uint32 = y


I'm just not seeing where a conversion issue is occurring in the above procedure...

lerxst2112 03-05-2013 12:55 AM

It isn't there, it's somewhere else the value is being used.

Here's an example from Client::Death()
Code:

        // now we apply the exp loss, unmem their spells, and make a corpse
        // unless they're a GM (or less than lvl 10
        if(!GetGM())
        {
                if(exploss > 0) {
                        int32 newexp = GetEXP();
                        if(exploss > newexp) {
                                //lost more than we have... wtf..
                                newexp = 1;
                        } else {
                                newexp -= exploss;
                        }
                        SetEXP(newexp, GetAAXP());
                        //m_epp.perAA = 0;        //reset to no AA exp on death.
                }

There may be more that are less obvious. Some of the rez and sacrifice code is suspect, but I'm too lazy to do the math.

Drajor 03-05-2013 01:23 AM

My source is a few weeks out of date but in Client::SetLevel the return value of GetEXPForLevel is being cast as a float numerous times. That would do it. Change float to double.

Quote:

float tmpxp = (float) ( (float) m_pp.exp - GetEXPForLevel( GetLevel() )) /
( (float) GetEXPForLevel(GetLevel()+1) - GetEXPForLevel(GetLevel()));
lu->exp = (uint32)(330.0f * tmpxp);
Holy sh*t wut!?

Drajor 03-05-2013 02:02 AM

Ugh I just realised exp is stored cumulatively..

lerxst2112 03-05-2013 01:55 PM

Float is probably ok there too. Without extracting that out into a test to see what the numbers are I'd guess you might lose a very small bit of precision, but a float isn't going to roll over to a negative number like a signed int would. Besides, that formula is just to tell the client how far to fill up the experience bar. If it was incorrect the server would still have the proper value and you'd level when you didn't expect it.

Armm 03-14-2013 01:44 PM

Try what i posted here... Works for me..

http://www.eqemulator.org/forums/sho...466#post219466


All times are GMT -4. The time now is 07:11 AM.

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