Create an account


Check for new replies
show exp by millions for lvl >= 496

#1
i recently reached lvl 496, and at lvl 496, your visible experiences goes to 0:
[Image: E3uHDB4.png]


this is a technical issue, in the 7.6 protocol, the experience is a `signed 32bit integer`, meaning max it can show is 2147483647, if you try to show higher than that, the client will *CRASH* or show a negative bogus value. to prevent the crash, YurOTS change it to 0 exp instead.


problem with this is:
[Image: ULwfgp0.png]

we can no longer deduce the exp/hour rate, so it's really hard to compare hunt spots for "which place gives the most exp/hour?"

i suggest that instead of changing it to zero exp, we should show the exp by millions-of-exp. now you will not have a problem at lvl 496, you will have a problem at level 50511 (at 2147608237913000 exp) instead, which is not a problem, nobody will get anywhere close to that level, and players can still check how much exp/hour we're getting.


now, assuming it's a YurOTS engine, that means in protocol76.cpp, find


Code:
void Protocol76::AddPlayerStats(NetworkMessage &msg,const Player *player)
{
    msg.AddByte(0xA0);
    msg.AddU16(player->getHealth());
    msg.AddU16(player->getPlayerInfo(PLAYERINFO_MAXHEALTH));
    msg.AddU16((unsigned short)std::floor(player->getFreeCapacity()));

#ifdef YUR_HIGH_LEVELS
    if (player->getPlayerInfo(PLAYERINFO_LEVEL) > 65535)
    {
        msg.AddU32(player->getPlayerInfo(PLAYERINFO_LEVEL));
        msg.AddU16(0);
    }
    else if (player->getExperience() > 2000000000L)
    {
        msg.AddU32(0);
        msg.AddU16(player->getPlayerInfo(PLAYERINFO_LEVEL));
    }
and simply replace

Code:
    else if (player->getExperience() > 2000000000L)
    {
        msg.AddU32(0);


with

Code:
    else if (player->getExperience() > 2000000000L)
    {
        msg.AddU32(uint32_t(player->getExperience() / 1000000)); // this is safe up to level 50511


- it's a 1-line change, and will allow us to calculate exp/h up to level 50,511.



- or, if for whatever reason you want the engine to be safe for levels even higher than level 50,511 then change it to:

Code:
    else if (player->getExperience() > 2000000000L)
    {
                 // someone over level 496
                const uint32_t tmp= uint32_t(player->getExperience() / 1000000);
                if( tmp > 2000000000L){
                    // someone over level 50511, i give up.
                   msg.addU32(0);      
                }else{
                    msg.addU32(tmp);
                }


made a video showcasing the effect of the code:
https://www.youtube.com/watch?v=Ph7PBMwAdhM
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum software by © MyBB Theme © iAndrew 2016
Powered By