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)

KingMort 03-03-2013 11:11 PM

I need to fix this folks
 
This Code is stock :

Code:

// Note: The client calculates exp separately, we cant change this function
// Add: You can set the values you want now, client will be always sync :) - Merkur
uint32 Client::GetEXPForLevel(uint16 check_level)
{

        uint16 check_levelm1 = check_level-1;
        float mod;
        if (check_level < 31)
                mod = 1.0;
        else if (check_level < 36)
                mod = 1.1;
        else if (check_level < 41)
                mod = 1.2;
        else if (check_level < 46)
                mod = 1.3;
        else if (check_level < 52)
                mod = 1.4;
        else if (check_level < 53)
                mod = 1.5;
        else if (check_level < 54)
                mod = 1.6;
        else if (check_level < 55)
                mod = 1.7;
        else if (check_level < 56)
                mod = 1.9;
        else if (check_level < 57)
                mod = 2.1;
        else if (check_level < 58)
                mod = 2.3;
        else if (check_level < 59)
                mod = 2.5;
        else if (check_level < 60)
                mod = 2.7;
        else if (check_level < 61)
                mod = 3.0;
        else
                mod = 3.1;
       
        float base = (check_levelm1)*(check_levelm1)*(check_levelm1);

        mod *= 1000;
       
        return(uint32(base * mod));
}

Alright well on raid Addicts we used some other code.. which didn't appear to me to be DRASTICALLY different, another GM I had made this code since we couldn't go past level 87.. Now when I am trying to remove this code and go with what you guys wrote, I can't keep any character on my server to what they were originally .. Max level on my server is 100, and they all revert to level 1.. I set them to 100 either by #setexp, or #level, and they just all revert BACK to level 1..

Please Help ! I want to go with what you guys wrote and not some weirdness but it seems my database is stuck on it's old ways.. Is there some way I can repair this issue?

At the top it says
Quote:

// Add: You can set the values you want now, client will be always sync :) - Merkur
but that's not ringing true right now , no offense :(

Morty

KingMort 03-03-2013 11:59 PM

I know i'm a total n00b by the way and please forgive me devs for even allowing my change to go in in the first place..

I have changed the code to this for now, and it seems to have fixed my problem however I still desire a vender recommended solution please :)


Code:

// Note: The client calculates exp separately, we cant change this function
// Add: You can set the values you want now, client will be always sync :) - Merkur
uint32 Client::GetEXPForLevel(uint16 check_level)
{

        uint16 check_levelm1 = check_level-1;
        float mod;
        if (check_level < 101)
                mod = 1.0;
        else if (check_level < 36)
                mod = 1.1;
        else if (check_level < 41)
                mod = 1.2;
        else if (check_level < 46)
                mod = 1.3;
        else if (check_level < 52)
                mod = 1.4;
        else if (check_level < 53)
                mod = 1.5;
        else if (check_level < 54)
                mod = 1.6;
        else if (check_level < 55)
                mod = 1.7;
        else if (check_level < 56)
                mod = 1.9;
        else if (check_level < 57)
                mod = 2.1;
        else if (check_level < 58)
                mod = 2.3;
        else if (check_level < 59)
                mod = 2.5;
        else if (check_level < 60)
                mod = 2.7;
        else if (check_level < 101)
                mod = 3.0;
        else
                mod = 3.1;
       
        float base = (check_levelm1)*(check_levelm1)*(check_levelm1);

        mod *= 1000;
       
        return(uint32(base * mod));
}


Drajor 03-04-2013 12:36 AM

I suggest checking if the value returned by GetEXPForLevel is being cast to a signed int anywhere. 3000(98^3) would be wrapping if that is the case (where going from lvl 99 to 100).

KingMort 03-04-2013 01:01 AM

Look dude, I don't speak dev that's why I've never posted in here :) Can you please send that in English? Love ya guys!

lerxst2112 03-04-2013 02:42 AM

Quote:

Originally Posted by KingMort (Post 219191)
Look dude, I don't speak dev

And this is why you fail.

KingMort 03-04-2013 12:06 PM

Yes I understand I "FAIL" because that is why I posted this so that I can get help with this and not "FAIL" ..

Please help me to understand how I can check the value returned by "GetEXPForLevel" ??

orionsun 03-04-2013 02:19 PM

You are the least technical network whatever you claim to be. Its basic stuff like this that undermines all the boasting you do lol.

Lets break this down...

Your code:
Code:

else if (check_level < 101)
                mod = 3.0;

The equation:
Code:

float base = (check_levelm1)*(check_levelm1)*(check_levelm1);
mod *= 1000;
return(uint32(base * mod))

Basic math time...

check_levelm1 = 100 <-- Character level(lets test max)
mod = 3.0 <-- This is the modifier a level 100 char has

base = 100 * 100 * 100 = 1,000,000
mod = 3.0 * 1000 = 3,000

return val = 1,000,000, * 3,000 = 3,000,000,000

The max value a uint32 can hold is ~2.14 billion.

A monkey could figure out where to go from here... good luck.

lerxst2112 03-04-2013 03:59 PM

The maximum value of a uint32 is 4,294,967,295. It's possible that is it being converted to a signed value somewhere along the way which would make anything over 2,147,483,647 become negative.

Drajor 03-04-2013 05:24 PM

Thanks guys for explaining this. I didn't have the patience yesterday.

wolfwalkereci 03-04-2013 07:17 PM

Quote:

Originally Posted by lerxst2112 (Post 219195)
And this is why you fail.

Quote:

Originally Posted by orionsun (Post 219209)
You are the least technical network whatever you claim to be. Its basic stuff like this that undermines all the boasting you do

Yeah that pretty much sums this clown up.

Zamthos 03-04-2013 07:38 PM

Mort, dude, didn't you just hire a 'brilliant' coder? Why couldn't he fix it? "Brilliant" and "better than me" are two different things, just saying. You've been doing this for 10 years, you should be able to speak in fluent C++ by now.

jimrocken 03-04-2013 07:50 PM

i don't see coding there except the maximum value a uint32 can hold (could google for that... just saying...)

it really is basic math... sorry mort but i kinda have to agree on this one... that was pretty simple...

Drajor 03-04-2013 08:42 PM

I had a go at expressing the exp curve as a single (mathematical) function. With those strange coefficients I think you could only get a pretty rough approximation because of the relatively large numbers being used.

To Mort: Try setting a character to level 89. If that works try setting them to 90. If setting them to 90 fails then this issue is almost certainly the result of an integer being cast incorrectly.

To fix that, search your code for references to GetEXPForLevel. Look for code that is simliar to 'int x = GetEXPForLevel(blah)' and change it to 'uint32 x = GetEXPForLevel(blah)'. If it is not that simple, then you will have to start looking at the uses of 'x' in other parts of the code.

KingMort 03-04-2013 09:27 PM

Thank you for the assistance will look into this. And thank you for the criticism and everything... Appreciate you all. Like I said in the beginning of the post as far as C++ stuff goes I am n00bsauce.. I don't mean to upset anyone by my questions here, I thought that this was a forum that was for Support not flames and rants. As a Network Analyst my job is to build networks, servers, and troubleshoot workstations, no where in my job description is coding of any kind. Apologies if you thought I had boasted about coding at some point? I can only ever remember telling people I suck at this . Please forgive my ignorance, I don't mean to upset anyone I just want to fix my problem.

Mort

Uleat 03-04-2013 09:39 PM

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


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

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