diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-03-22 12:06:36 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-03-22 12:06:36 +0300 |
commit | 0e7aa4918ba0a6dd94076e5f75725faabe483f69 (patch) | |
tree | 27f15c3b4d3853a03382dc66a13cfd91f169be6f | |
parent | a39ca8e69e759daca60bd7f6cb2d5cb827d98893 (diff) | |
download | manaverse-0e7aa4918ba0a6dd94076e5f75725faabe483f69.tar.gz manaverse-0e7aa4918ba0a6dd94076e5f75725faabe483f69.tar.bz2 manaverse-0e7aa4918ba0a6dd94076e5f75725faabe483f69.tar.xz manaverse-0e7aa4918ba0a6dd94076e5f75725faabe483f69.zip |
Send login server ping packets if server support it.
-rw-r--r-- | src/client.cpp | 24 | ||||
-rw-r--r-- | src/client.h | 3 |
2 files changed, 27 insertions, 0 deletions
diff --git a/src/client.cpp b/src/client.cpp index 479bd3b3b..5d8978910 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -218,6 +218,7 @@ Client::Client() : mSkin(nullptr), mButtonPadding(1), mButtonSpacing(3), + mPing(0), mConfigAutoSaved(false) { WindowManager::init(); @@ -780,6 +781,7 @@ int Client::gameExec() gui->slowLogic(); if (mGame) mGame->slowLogic(); + slowLogic(); BLOCK_END("Client::gameExec 4") // This is done because at some point tick_time will wrap. @@ -1144,6 +1146,7 @@ int Client::gameExec() case STATE_UPDATE: BLOCK_START("Client::gameExec STATE_UPDATE") logger->log1("State: UPDATE"); + // Determine which source to use for the update host if (!settings.options.updateHost.empty()) settings.updateHost = settings.options.updateHost; @@ -1789,6 +1792,27 @@ void Client::logVars() #endif } +void Client::slowLogic() +{ + if (!gameHandler || !gameHandler->mustPing()) + return; + + if (get_elapsed_time1(mPing) > 1500) + { + mPing = tick_time; + if (mState != STATE_UPDATE && + mState != STATE_LOGIN && + mState != STATE_LOGIN_ATTEMPT) + { + return; + } + if (loginHandler) + loginHandler->ping(); + if (generalHandler) + generalHandler->flushSend(); + } +} + #ifdef ANDROID #ifdef USE_SDL2 /* diff --git a/src/client.h b/src/client.h index 079ed90ec..791425ae5 100644 --- a/src/client.h +++ b/src/client.h @@ -95,6 +95,8 @@ class Client final : public ConfigListener, void windowRemoved(const Window *const window); + void slowLogic(); + static void setEnv(const char *const name, const char *const value); private: @@ -135,6 +137,7 @@ class Client final : public ConfigListener, Skin *mSkin; int mButtonPadding; int mButtonSpacing; + int mPing; bool mConfigAutoSaved; }; |