• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

Add Ping - OTX 2

C

CWMsollutions

Guest
Just open tfs1.2 sources and copy and paste function responsible for ping to your server
 
OP
OP
potinho

potinho

Well-Known Member
Joined
Oct 11, 2009
Messages
1,086
Solutions
18
Reaction score
83
Location
Brazil
You can find all the server source modification here
my server dont have data/events/scripts/player.lua, believe because old engine (OTX 2)

Now ping is enabled but show a incorrect value, i dont have lag.

1657570539232.png

Someone can help me fix this?
 

Extrodus

|| Blazera.net ||
Premium User
Joined
Dec 22, 2008
Messages
2,566
Solutions
6
Reaction score
413
Location
Canada
I can try yelling "WORK DAMN YOU!" at the pictures you provided but probably would do better if you provided the code for the ping where it checks connection strength/ping so we can see why/where the values are coming from. For all we know, the values are technically displaying correctly and the script isn't modified to ping your server but instead pings another IP which you indeed have a bad connection too.

TL/DR: Provide code for analysis.
 
OP
OP
potinho

potinho

Well-Known Member
Joined
Oct 11, 2009
Messages
1,086
Solutions
18
Reaction score
83
Location
Brazil
I can try yelling "WORK DAMN YOU!" at the pictures you provided but probably would do better if you provided the code for the ping where it checks connection strength/ping so we can see why/where the values are coming from. For all we know, the values are technically displaying correctly and the script isn't modified to ping your server but instead pings another IP which you indeed have a bad connection too.

TL/DR: Provide code for analysis.
Here ping stuffs that i have in my sources

at game.cpp
C++:
bool Game::playerReceivePing(uint32_t playerId)
{
    Player* player = getPlayerByID(playerId);
    if(!player || player->isRemoved())
        return false;

    player->receivePing();
    return true;
}

player.cpp
C++:
    lastLoad = lastPing = lastPong = lastAttack = lastMail = OTSYS_TIME();
AND
Code:
void Player::onThink(uint32_t interval)
{
    Creature::onThink(interval);
    int64_t timeNow = OTSYS_TIME();
    if(timeNow - lastPing >= 5000)
    {
        lastPing = timeNow;
        if(hasClient())
            client->sendPing();
        else if(g_config.getBool(ConfigManager::STOP_ATTACK_AT_EXIT))
            setAttackedCreature(NULL);
    }

    if((timeNow - lastPong) >= 60000 && !getTile()->hasFlag(TILESTATE_NOLOGOUT)
        && !isConnecting && !pzLocked && !hasCondition(CONDITION_INFIGHT))
    {
        if(hasClient())
            client->logout(true, true);
        else if(g_creatureEvents->playerLogout(this, false))
            g_game.removeCreature(this, true);
    }

    messageTicks += interval;
    if(messageTicks >= 1500)
    {
        messageTicks = 0;
        addMessageBuffer();
    }

player.h
Code:
        void receivePing() {lastPong = OTSYS_TIME();}
        virtual void onThink(uint32_t interval);
and
Code:
        int64_t lastPong;
        int64_t lastPing;

at protocolgame.cpp
C++:
void ProtocolGame::parseReceivePing(NetworkMessage&)
{
    addGameTask(&Game::playerReceivePing, player->getID());
and
C++:
        void sendPing();

spectators.h
C++:
        void sendPing()
        {
            if(!owner)
                return;

            owner->sendPing();
            for(SpectatorList::iterator it = spectators.begin(); it != spectators.end(); ++it)
                it->first->sendPing();
        }
 
Top