Ping System (OTHire)

Discussion in 'OTClient' started by Vantoria, Oct 10, 2018.

  1. Vantoria

    Vantoria www.ClassicOT.us

    Joined:
    Jun 6, 2014
    Messages:
    98
    Likes Received:
    9
    Best Answers:
    0
    Hello i have an otclient compiled with ping system but i cant get it work in OTHire, i tryed the ping system with tibianic client sources and it Works perfectly so what is the problem between othire and otclient?
    [​IMG]
     
  2. secondlife

    secondlife Member

    Joined:
    Aug 1, 2009
    Messages:
    225
    Likes Received:
    16
    Best Answers:
    0
    you need to add the respective functions for this system works (ServerSide)

    The default sources from othire dont support this feature.
     
  3. Mr Trala

    Mr Trala Active Member

    Joined:
    Aug 26, 2014
    Messages:
    127
    Likes Received:
    60
    Best Answers:
    7
  4. Gesior.pl

    Gesior.pl Mega Noob&LOL 2012 Premium User

    Joined:
    Sep 18, 2007
    Messages:
    1,921
    Likes Received:
    823
    Best Answers:
    11
    OTHire from Github is for protocol 7.72.

    In Tibia there was 2 versions of 'ping'. One called 'ping' and second 'ping back'.

    One was only to check if connection to client work.
    Other did measure ping between server and client.

    'ping' was added in Tibia 9.53:
    edubart/otclient

    and OTClient make it work/show result only when you set version 9.53+.

    If you added it to server, you can try to force it in OTClient.
    AFTER you load list of characters (in this moment client enables features based on selected client version). Open 'Terminal' and type:
    PHP:
    1. g_game.enableFeature(GameClientPing)
    Then login to game and check if it shows ping.
     
    69lmao420 and Vantoria like this.
  5. Vantoria

    Vantoria www.ClassicOT.us

    Joined:
    Jun 6, 2014
    Messages:
    98
    Likes Received:
    9
    Best Answers:
    0
    the problema is that i'm using a custom otc so it dont have Terminal window but i was wondering why the ping system Works on Tibianic client? because othire already have implemented the ping system so there is no way to edit the functions in otclient to fetch more o less to othire?
     
  6. Madzix

    Madzix Member

    Joined:
    Sep 8, 2016
    Messages:
    46
    Likes Received:
    57
    Best Answers:
    9
    Tibianic DLL sources use ICMP to check ping which is different than client-server ping-pong. ICMP will not show you the extra latency caused by cpu usage of client/server but rather the minimal ping you can have to the server.
     
    Okke likes this.
  7. Vantoria

    Vantoria www.ClassicOT.us

    Joined:
    Jun 6, 2014
    Messages:
    98
    Likes Received:
    9
    Best Answers:
    0
    well i just wanted to make my client look like more helpful but its alright man thank you right, i Will use my client like it is without the ping system :D
     
  8. ruth

    ruth Active Member

    Joined:
    Aug 3, 2009
    Messages:
    419
    Likes Received:
    105
    Best Answers:
    2
    Vantoria likes this.
  9. Vantoria

    Vantoria www.ClassicOT.us

    Joined:
    Jun 6, 2014
    Messages:
    98
    Likes Received:
    9
    Best Answers:
    0
    thanks @ruth i have one personal question how i can pack or compress the otclient? i have been looking in Google any program similar to molebox but i cant add the folder Modules i just can add the libs i really want to compress it like you do with yours i mean if it is posible ofcourse
     
  10. Felipe93

    Felipe93 Ghost Member

    Joined:
    Mar 21, 2015
    Messages:
    1,066
    Likes Received:
    142
    Best Answers:
    5
    did u fix the ping issue?
    if you did. can u share the fix please?
     
  11. Vantoria

    Vantoria www.ClassicOT.us

    Joined:
    Jun 6, 2014
    Messages:
    98
    Likes Received:
    9
    Best Answers:
    0
    no i didnt try the fix that @ruth post here but u can try it maybe? i didnt have time for compile the otc
     
  12. Felipe93

    Felipe93 Ghost Member

    Joined:
    Mar 21, 2015
    Messages:
    1,066
    Likes Received:
    142
    Best Answers:
    5
    aight thanks
     
  13. 4drik

    4drik Active Member

    Joined:
    Jun 30, 2014
    Messages:
    149
    Likes Received:
    71
    Best Answers:
    0
    I have implemented a ping system from TFS to YurOTS today.
    It works perfectly.

    All you have to do is copy, paste & adapt the code to your engine.
    otland/forgottenserver
    otland/forgottenserver
    And then go to
    Code (Text):
    1.  
    2. OTClient\modules\game_things\things.lua
    3.  
    and in function load() add
    Code (Text):
    1.  
    2. g_game.enableFeature(GameClientPing)
    3.  
    And that's it :)
     
  14. Vantoria

    Vantoria www.ClassicOT.us

    Joined:
    Jun 6, 2014
    Messages:
    98
    Likes Received:
    9
    Best Answers:
    0
    YurOTS its based in tfs? because i did try to add that last week to othire but without successfull and othire is based in OTServ as i know
     
  15. Felipe93

    Felipe93 Ghost Member

    Joined:
    Mar 21, 2015
    Messages:
    1,066
    Likes Received:
    142
    Best Answers:
    5
    you'll have to edit the code you cant copy paste everything i'll try to add it after i finish to add new creature events to OTH and mods handler folder to OTH src
    to be able to use ctf, zombie event etc
    [OTHIRE 1.0]With cast system (buggy yet) and others features
    cast sys is not bugged solved by olddies but those src aint updated
    i'll create a new thread in a near future
     
    Last edited: Oct 15, 2018
  16. 4drik

    4drik Active Member

    Joined:
    Jun 30, 2014
    Messages:
    149
    Likes Received:
    71
    Best Answers:
    0
    YurOTS is not based on TFS. YurOTS is based on CVS from 2005-12-28. It is the oldest still used engine.
    Without modifying the ping code, of course, it would not work, but these changes were small. It's probably even smaller for OTHire.
     
  17. Vantoria

    Vantoria www.ClassicOT.us

    Joined:
    Jun 6, 2014
    Messages:
    98
    Likes Received:
    9
    Best Answers:
    0
    ok thanks to @Olddies who send me the edited files and for now it seems to work, right now the problem is i get disconnected from the game after 1 minute if i dont move i get disconnected if i keep moving myself it dont disconnect me so i think now i'm more closer to it… by the way @Olddies i hope you could help me tomorrow again please :)

    [​IMG]
     
  18. Felipe93

    Felipe93 Ghost Member

    Joined:
    Mar 21, 2015
    Messages:
    1,066
    Likes Received:
    142
    Best Answers:
    5
    share the code to see if we can do something with it
     
  19. Olddies

    Olddies www.the-realots.online

    Joined:
    Nov 21, 2009
    Messages:
    698
    Likes Received:
    115
    Best Answers:
    2
    here you go guys the code is working and tested by me i make the tutorial easy for you guys so follow it and you wont have any problems

    Player.h around line 900
    Code (Text):
    1.     void sendPing();
    2.     void sendPingBack() const {
    3.         if (client) {
    4.             client->sendPingBack();
    5.         }
    6.     }

    Player.h add or replace around line 985
    Code (Text):
    1.     void receivePing() {
    2.         lastPong = OTSYS_TIME();
    3.     }

    Player.h around line 1108
    Code (Text):
    1.     int64_t lastPing;
    2.     int64_t lastPong;

    Protocolgame.h look for this
    Code (Text):
    1. void parseReceivePing(NetworkMessage& msg);
    and add this below
    Code (Text):
    1.     void parseReceivePingBack(NetworkMessage& msg);

    Protocolgame.h around line 192
    Code (Text):
    1.     void sendPing();
    2.     void sendPingBack();

    Game.h around line 505
    Code (Text):
    1.     bool playerReceivePing(uint32_t playerId);
    2.     bool playerReceivePingBack(uint32_t playerId);

    Protocolgame.cpp around line 516
    Code (Text):
    1.         case 0x1D:
    2.             addGameTask(&Game::playerReceivePingBack, player->getID());
    3.             break;

    Protocolgame.cpp around line 553
    Code (Text):
    1.         case 0x1D: // keep alive / ping response
    2.             parseReceivePingBack(msg);
    3.             break;

    Protocolgame.cpp around line 1090
    Code (Text):
    1. void ProtocolGame::parseReceivePingBack(NetworkMessage& msg)
    2. {
    3.   addGameTask(&Game::playerReceivePingBack, player->getID());
    4. }

    Protocolgame.cpp around line 1905
    Code (Text):
    1. void ProtocolGame::sendPing()
    2. {
    3.     NetworkMessage_ptr msg = getOutputBuffer();
    4.     if(msg){
    5.         TRACK_MESSAGE(msg);
    6.         msg->AddByte(0x1E);
    7.     }
    8. }
    9.  
    10. void ProtocolGame::sendPingBack()
    11. {
    12.     NetworkMessage_ptr msg = getOutputBuffer();
    13.     if(msg){
    14.         TRACK_MESSAGE(msg);
    15.         msg->AddByte(0x1D);
    16.     }
    17. }

    Game.cpp around line 2250
    Code (Text):
    1. bool Game::playerReceivePing(uint32_t playerId)
    2. {
    3.     Player* player = getPlayerByID(playerId);
    4.     if(!player || player->isRemoved())
    5.         return false;
    6.  
    7.     player->receivePing();
    8.     return true;
    9. }
    10.  
    11. bool Game::playerReceivePingBack(uint32_t playerId)
    12. {
    13.     Player* player = getPlayerByID(playerId);
    14.     if(!player || player->isRemoved())
    15.         return false;
    16.  
    17.     player->sendPingBack();
    18.     return true;
    19. }

    Player.cpp look for this and remove it
    Code (Text):
    1.     lastping = OTSYS_TIME();
    2.     lastpong = OTSYS_TIME();

    Player.cpp add after this
    Code (Text):
    1. Player::Player(const std::string& _name, ProtocolGame* p) :
    add this
    Code (Text):
    1. Creature(), lastPing(OTSYS_TIME()), lastPong(lastPing)


    Player.cpp after this
    Code (Text):
    1. void Player::sendStats()
    2. {
    3.     if(client){
    4.         client->sendStats();
    5.     }
    6. }
    add this
    Code (Text):
    1. void Player::sendPing()
    2. {
    3.     int64_t timeNow = OTSYS_TIME();
    4.  
    5.     bool hasLostConnection = false;
    6.     if ((timeNow - lastPing) >= 5000){
    7.         lastPing = timeNow;
    8.         if (client) {
    9.             client->sendPing();
    10.         } else {
    11.             hasLostConnection = true;
    12.         }
    13.     }
    14.  
    15.     int64_t noPongTime = timeNow - lastPong;
    16.     if ((hasLostConnection || noPongTime >= 7000) && attackedCreature && attackedCreature->getPlayer()) {
    17.         setAttackedCreature(nullptr);
    18.     }
    19.  
    20.     if(OTSYS_TIME() - lastPong >= 60000){
    21.         if(canLogout()){
    22.             if(client){
    23.                 client->logout(true);
    24.             }
    25.             else{
    26.                 g_game.removeCreature(this, true);
    27.             }
    28.         }
    29.     }
    30. }
    31.  

    Otclient/modules/game_things/things.lua
    Code (Text):
    1. g_game.enableFeature(GameClientPing)

    if you have any issue with it post here i will try to help when i can
     
    Last edited: Oct 21, 2018 at 11:03 PM
    Vantoria and Peonso like this.
  20. Vantoria

    Vantoria www.ClassicOT.us

    Joined:
    Jun 6, 2014
    Messages:
    98
    Likes Received:
    9
    Best Answers:
    0
    :D :D thank you so much @Olddies :O i dont see the best answer option i wish give it to you :)
     

Share This Page

Loading...