summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-06-24 22:54:00 +0300
committerAndrei Karas <akaras@inbox.ru>2012-06-24 22:54:00 +0300
commitf9feb8f1fd4e2dc56218aba40ef94962fa866f84 (patch)
tree9d2f50f84f74e158b4a1d508d59fe17c55e3a17b /src
parent2e655b41861169ee1db19ef59345661b7dc70610 (diff)
downloadmanaverse-f9feb8f1fd4e2dc56218aba40ef94962fa866f84.tar.gz
manaverse-f9feb8f1fd4e2dc56218aba40ef94962fa866f84.tar.bz2
manaverse-f9feb8f1fd4e2dc56218aba40ef94962fa866f84.tar.xz
manaverse-f9feb8f1fd4e2dc56218aba40ef94962fa866f84.zip
Fix disconnect by timeout in eathena servers.
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp11
-rw-r--r--src/game.h1
-rw-r--r--src/net/eathena/gamehandler.h3
-rw-r--r--src/net/gamehandler.h2
-rw-r--r--src/net/manaserv/gamehandler.h3
-rw-r--r--src/net/tmwa/gamehandler.h3
6 files changed, 21 insertions, 2 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 386e01a3d..9aad672da 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -367,7 +367,8 @@ Game::Game():
mLastAction(0),
mNextAdjustTime(cur_time + adjustDelay),
mAdjustLevel(0),
- mLowerCounter(0)
+ mLowerCounter(0),
+ mPing(0)
{
spellManager = new SpellManager;
spellShortcut = new SpellShortcut;
@@ -615,6 +616,13 @@ void Game::slowLogic()
}
else
{
+ if (Net::getGameHandler()->mustPing()
+ && get_elapsed_time1(mPing) > 3000)
+ {
+ mPing = tick_time;
+ Net::getGameHandler()->ping(tick_time);
+ }
+
if (mAdjustPerfomance)
adjustPerfomance();
if (disconnectedDialog)
@@ -623,7 +631,6 @@ void Game::slowLogic()
disconnectedDialog = nullptr;
}
}
-
}
void Game::adjustPerfomance()
diff --git a/src/game.h b/src/game.h
index b411f2b0f..ec49fafe1 100644
--- a/src/game.h
+++ b/src/game.h
@@ -134,6 +134,7 @@ class Game
int mAdjustLevel;
bool mAdjustPerfomance;
int mLowerCounter;
+ int mPing;
static Game *mInstance;
};
diff --git a/src/net/eathena/gamehandler.h b/src/net/eathena/gamehandler.h
index c7c45a177..a1f6c46e7 100644
--- a/src/net/eathena/gamehandler.h
+++ b/src/net/eathena/gamehandler.h
@@ -58,6 +58,9 @@ class GameHandler : public MessageHandler, public Ea::GameHandler
void mapLoadedEvent();
void processMapCharId(Net::MessageIn &msg);
+
+ bool mustPing() const
+ { return true; }
};
} // namespace EAthena
diff --git a/src/net/gamehandler.h b/src/net/gamehandler.h
index fd051234f..a9713a30a 100644
--- a/src/net/gamehandler.h
+++ b/src/net/gamehandler.h
@@ -56,6 +56,8 @@ class GameHandler
* Tells whether the protocol is using the MP status bar
*/
virtual bool canUseMagicBar() const = 0;
+
+ virtual bool mustPing() const = 0;
};
} // namespace Net
diff --git a/src/net/manaserv/gamehandler.h b/src/net/manaserv/gamehandler.h
index 2019755ea..938509b4d 100644
--- a/src/net/manaserv/gamehandler.h
+++ b/src/net/manaserv/gamehandler.h
@@ -65,6 +65,9 @@ class GameHandler : public MessageHandler, public Net::GameHandler
{ return false; }
void disconnect2();
+
+ bool mustPing() const
+ { return false; }
};
} // namespace ManaServ
diff --git a/src/net/tmwa/gamehandler.h b/src/net/tmwa/gamehandler.h
index d48fabdcc..455ec3646 100644
--- a/src/net/tmwa/gamehandler.h
+++ b/src/net/tmwa/gamehandler.h
@@ -56,6 +56,9 @@ class GameHandler : public MessageHandler, public Ea::GameHandler
void disconnect2();
void mapLoadedEvent();
+
+ bool mustPing() const
+ { return false; }
};
} // namespace TmwAthena