• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

show exp for very high levels (>=507) on older clients

hans henrik

Active Member
Joined
Jun 5, 2007
Messages
314
Reaction score
38
Location
Norway
i think cipsoft changed to 64bit exp at some point (anyone know when?),
but older clients (at least the 7.6 client) use 32bit SIGNED (wtf cipsoft? it should have been unsigned at least) integers for experience, which will break after lvl 507,

here's code to display for level:

<= 507: show real exp.
after level 507, show exp in millions.
after lvl 50510, show exp in billions.
after lvl 5050804, show exp in trillions.
after lvl 50508025, show exp in quadrillions.
after lvl 505080234, show exp in quintillions.
after lvl 505080235, show level the instead of experience.
and after lvl 2147483647, just show 0 in exp. (i don't think any engine is actually capable of going this high anyway, it would require the engine to use int128_t instead of int64_t, i'm not even sure int128 could go that far, i haven't done the math though)

this is written in TFS 0.3.6 style (because i'm programming for someone running a 7.6 server with a TFS0.3.6 engine ported to 7.6, there's another WTF right there),
but it should be easy to port to other versions

C++:
const uint64_t experience = player->getExperience();
    const uint64_t num_million = uint64_t(1000000);
    const uint64_t num_billion = uint64_t(1000000000);
    const uint64_t num_trillion = uint64_t(1000000000000);
    const uint64_t num_quadrillion = uint64_t(1000000000000000);
    const uint64_t num_quintillion = uint64_t(1000000000000000000);

    if(experience <= INT32_MAX)
    {
        // level <= 507, show actual exp
        msg->put<uint32_t>(experience);
    } else if(experience < (INT32_MAX * NUM_MILLION))
    {
        // level <= 50510, show exp in millions
        msg->put<uint32_t>(uint32_t((experience/NUM_MILLION)));
    } else if (experience < (INT32_MAX * num_billion) )
    {
        // level <= 505082, show exp in billions
        msg->put<uint32_t>(uint32_t((experience/num_billion)));
    } else if (experience < (INT32_MAX * num_trillion))
    {
        // level <= 5050804, show exp in trillions
        msg->put<uint32_t>(uint32_t((experience/num_trillion)));
    } else if ( experience < (INT32_MAX * num_quadrillion))
    {
        // level <= 50508025, show exp in quadrillions
        msg->put<uint32_t>(uint32_t((experience/num_quadrillion)));         
    } else if ( experience < (INT32_MAX * num_quintillion))
    {
        // level <= 505080234, show exp in quintillions
        msg->put<uint32_t>(uint32_t((experience/num_quadrillion)));         
    } else {
        // ... level >= 505080235,
        // we give up, show the level instead.
        const uint64_t level = player->getPlayerInfo(PLAYERINFO_LEVEL);
        if(level > INT32_MAX) {
            // level > 2147483647 , give up, just display 0 experience
                msg->put<uint32_t>(uint32_t(0));
        } else {
            // level between 505080235 - 2147483647,
            // show the level in exp bar.
            msg->put<uint32_t>(uint32_t(level));
        }
    }
 
cool... but why? 🤦‍♂️
"Experience: 0" conveys no useful information
1599298430910.png
and if you cavebot with "Experience 0", your cavebot will say Experience per hour: 0
1599298563282.png
which makes it difficult to compare huntspots to figure out which huntspot gives most per exp per hour~
 
Back
Top