summaryrefslogtreecommitdiff
path: root/src/net/manaserv
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2010-02-21 20:40:07 +0100
committerChuck Miller <shadowmil@gmail.com>2010-02-21 17:05:40 -0500
commitc8b0d1e56f27c3141895d28b2fc768afffe7bb2d (patch)
tree0a03458836badee3e1b0da13a0721c9261e7fa86 /src/net/manaserv
parent204a14c91bbe4436eb3b26bebf30cbe5669bdd1a (diff)
downloadmana-c8b0d1e56f27c3141895d28b2fc768afffe7bb2d.tar.gz
mana-c8b0d1e56f27c3141895d28b2fc768afffe7bb2d.tar.bz2
mana-c8b0d1e56f27c3141895d28b2fc768afffe7bb2d.tar.xz
mana-c8b0d1e56f27c3141895d28b2fc768afffe7bb2d.zip
Made tick counter and framerate limiter work during login sequence
Much code was moved from main() to the new Client::exec(). This new event loop now integrates with the Game class, so that the tick counter and framerate limiter apply universally. The Client class is also responsible for some things that used to be global variables. Mantis-issue: ...
Diffstat (limited to 'src/net/manaserv')
-rw-r--r--src/net/manaserv/beinghandler.cpp7
-rw-r--r--src/net/manaserv/charhandler.cpp9
-rw-r--r--src/net/manaserv/chathandler.cpp5
-rw-r--r--src/net/manaserv/gamehandler.cpp6
-rw-r--r--src/net/manaserv/generalhandler.cpp6
-rw-r--r--src/net/manaserv/loginhandler.cpp36
-rw-r--r--src/net/manaserv/playerhandler.cpp4
7 files changed, 34 insertions, 39 deletions
diff --git a/src/net/manaserv/beinghandler.cpp b/src/net/manaserv/beinghandler.cpp
index 86f86d3f..bab5471b 100644
--- a/src/net/manaserv/beinghandler.cpp
+++ b/src/net/manaserv/beinghandler.cpp
@@ -23,13 +23,12 @@
#include "being.h"
#include "beingmanager.h"
+#include "client.h"
#include "game.h"
#include "localplayer.h"
#include "log.h"
-#include "main.h"
#include "npc.h"
#include "particle.h"
-#include "sound.h"
#include "gui/okdialog.h"
@@ -103,10 +102,10 @@ Vector BeingHandler::giveSpeedInPixelsPerTicks(float speedInTilesPerSeconds)
{
speedInTicks.x = speedInTilesPerSeconds
* (float)map->getTileWidth()
- / 1000 * (float)MILLISECONDS_IN_A_TICK;
+ / 1000 * (float) MILLISECONDS_IN_A_TICK;
speedInTicks.y = speedInTilesPerSeconds
* (float)map->getTileHeight()
- / 1000 * (float)MILLISECONDS_IN_A_TICK;
+ / 1000 * (float) MILLISECONDS_IN_A_TICK;
}
}
diff --git a/src/net/manaserv/charhandler.cpp b/src/net/manaserv/charhandler.cpp
index 14d2b11f..4b574821 100644
--- a/src/net/manaserv/charhandler.cpp
+++ b/src/net/manaserv/charhandler.cpp
@@ -21,10 +21,9 @@
#include "net/manaserv/charhandler.h"
-#include "game.h"
+#include "client.h"
#include "localplayer.h"
#include "log.h"
-#include "main.h"
#include "gui/charcreatedialog.h"
#include "gui/okdialog.h"
@@ -236,14 +235,14 @@ void CharHandler::handleCharacterSelectResponse(Net::MessageIn &msg)
mCachedCharacterInfos.clear();
updateCharacters();
- state = STATE_CONNECT_GAME;
+ Client::setState(STATE_CONNECT_GAME);
}
else if (errMsg == ERRMSG_FAILURE)
{
errorMessage = _("No gameservers are available.");
delete_all(mCharacters);
mCharacters.clear();
- state = STATE_ERROR;
+ Client::setState(STATE_ERROR);
}
}
@@ -280,7 +279,7 @@ void CharHandler::requestCharacters()
else
{
// The characters are already there, continue to character selection
- state = STATE_CHAR_SELECT;
+ Client::setState(STATE_CHAR_SELECT);
}
}
diff --git a/src/net/manaserv/chathandler.cpp b/src/net/manaserv/chathandler.cpp
index d6da557d..a452281f 100644
--- a/src/net/manaserv/chathandler.cpp
+++ b/src/net/manaserv/chathandler.cpp
@@ -23,10 +23,9 @@
#include "being.h"
#include "beingmanager.h"
+#include "client.h"
#include "channel.h"
#include "channelmanager.h"
-#include "game.h"
-#include "main.h"
#include "gui/chat.h"
@@ -136,7 +135,7 @@ void ChatHandler::handleMessage(Net::MessageIn &msg)
errorMessage = "Chatserver: Unknown error";
break;
}
- state = STATE_ERROR;
+ Client::setState(STATE_ERROR);
}
}
break;
diff --git a/src/net/manaserv/gamehandler.cpp b/src/net/manaserv/gamehandler.cpp
index a7d979a1..dd6120ae 100644
--- a/src/net/manaserv/gamehandler.cpp
+++ b/src/net/manaserv/gamehandler.cpp
@@ -21,8 +21,8 @@
#include "net/manaserv/gamehandler.h"
+#include "client.h"
#include "localplayer.h"
-#include "main.h"
#include "net/manaserv/chathandler.h"
#include "net/manaserv/connection.h"
@@ -63,7 +63,7 @@ void GameHandler::handleMessage(Net::MessageIn &msg)
\
if (!netToken.empty())
{
- state = STATE_SWITCH_CHARACTER;
+ Client::setState(STATE_SWITCH_CHARACTER);
}
else
{
@@ -82,7 +82,7 @@ void GameHandler::handleMessage(Net::MessageIn &msg)
errorMessage = "Gameserver: Unknown error";
break;
}
- state = STATE_ERROR;
+ Client::setState(STATE_ERROR);
}
}
break;
diff --git a/src/net/manaserv/generalhandler.cpp b/src/net/manaserv/generalhandler.cpp
index 9f14fd38..171ca214 100644
--- a/src/net/manaserv/generalhandler.cpp
+++ b/src/net/manaserv/generalhandler.cpp
@@ -21,7 +21,7 @@
#include "net/manaserv/generalhandler.h"
-#include "main.h"
+#include "client.h"
#include "gui/changeemaildialog.h"
#include "gui/charselectdialog.h"
@@ -147,11 +147,11 @@ void GeneralHandler::flushNetwork()
{
flush();
- if (state == STATE_SWITCH_CHARACTER &&
+ if (Client::getState() == STATE_SWITCH_CHARACTER &&
Net::getLoginHandler()->isConnected())
{
loginHandler->reconnect();
- state = STATE_GET_CHARACTERS;
+ Client::setState(STATE_GET_CHARACTERS);
}
}
diff --git a/src/net/manaserv/loginhandler.cpp b/src/net/manaserv/loginhandler.cpp
index a8395204..cbc8e510 100644
--- a/src/net/manaserv/loginhandler.cpp
+++ b/src/net/manaserv/loginhandler.cpp
@@ -21,7 +21,7 @@
#include "net/manaserv/loginhandler.h"
-#include "main.h"
+#include "client.h"
#include "net/logindata.h"
@@ -75,7 +75,7 @@ void LoginHandler::handleMessage(Net::MessageIn &msg)
// Successful login
if (errMsg == ERRMSG_OK)
{
- state = STATE_CHAR_SELECT;
+ Client::setState(STATE_CHAR_SELECT);
}
// Login failed
else
@@ -95,7 +95,7 @@ void LoginHandler::handleMessage(Net::MessageIn &msg)
errorMessage = _("Unknown error.");
break;
}
- state = STATE_ERROR;
+ Client::setState(STATE_ERROR);
}
}
break;
@@ -106,7 +106,7 @@ void LoginHandler::handleMessage(Net::MessageIn &msg)
// Successful pass change
if (errMsg == ERRMSG_OK)
{
- state = STATE_CHANGEPASSWORD_SUCCESS;
+ Client::setState(STATE_CHANGEPASSWORD_SUCCESS);
}
// pass change failed
else
@@ -126,7 +126,7 @@ void LoginHandler::handleMessage(Net::MessageIn &msg)
errorMessage = _("Unknown error.");
break;
}
- state = STATE_ACCOUNTCHANGE_ERROR;
+ Client::setState(STATE_ACCOUNTCHANGE_ERROR);
}
}
break;
@@ -137,7 +137,7 @@ void LoginHandler::handleMessage(Net::MessageIn &msg)
// Successful pass change
if (errMsg == ERRMSG_OK)
{
- state = STATE_CHANGEEMAIL_SUCCESS;
+ Client::setState(STATE_CHANGEEMAIL_SUCCESS);
}
// pass change failed
else
@@ -160,7 +160,7 @@ void LoginHandler::handleMessage(Net::MessageIn &msg)
errorMessage = _("Unknown error.");
break;
}
- state = STATE_ACCOUNTCHANGE_ERROR;
+ Client::setState(STATE_ACCOUNTCHANGE_ERROR);
}
}
break;
@@ -185,7 +185,7 @@ void LoginHandler::handleMessage(Net::MessageIn &msg)
errorMessage = "Accountserver: Unknown error";
break;
}
- state = STATE_ERROR;
+ Client::setState(STATE_ERROR);
}
}
break;
@@ -195,7 +195,7 @@ void LoginHandler::handleMessage(Net::MessageIn &msg)
// Successful unregistration
if (errMsg == ERRMSG_OK)
{
- state = STATE_UNREGISTER;
+ Client::setState(STATE_UNREGISTER);
}
// Unregistration failed
else
@@ -210,7 +210,7 @@ void LoginHandler::handleMessage(Net::MessageIn &msg)
errorMessage = "Accountserver: Unknown error";
break;
}
- state = STATE_ACCOUNTCHANGE_ERROR;
+ Client::setState(STATE_ACCOUNTCHANGE_ERROR);
}
}
break;
@@ -228,7 +228,7 @@ void LoginHandler::handleMessage(Net::MessageIn &msg)
printf("%s: %s\n", captchaURL.c_str(), captchaInstructions.c_str());
- state = STATE_REGISTER;
+ Client::setState(STATE_REGISTER);
}
else
{
@@ -237,7 +237,7 @@ void LoginHandler::handleMessage(Net::MessageIn &msg)
if (errorMessage.empty())
errorMessage = _("Client registration is not allowed. "
"Please contact server administration.");
- state = STATE_LOGIN_ERROR;
+ Client::setState(STATE_LOGIN_ERROR);
}
}
break;
@@ -252,7 +252,7 @@ void LoginHandler::handleLoginResponse(Net::MessageIn &msg)
{
readUpdateHost(msg);
// No worlds atm, but future use :-D
- state = STATE_WORLD_SELECT;
+ Client::setState(STATE_WORLD_SELECT);
}
else
{
@@ -278,7 +278,7 @@ void LoginHandler::handleLoginResponse(Net::MessageIn &msg)
errorMessage = _("Unknown error.");
break;
}
- state = STATE_LOGIN_ERROR;
+ Client::setState(STATE_LOGIN_ERROR);
}
}
@@ -289,7 +289,7 @@ void LoginHandler::handleRegisterResponse(Net::MessageIn &msg)
if (errMsg == ERRMSG_OK)
{
readUpdateHost(msg);
- state = STATE_WORLD_SELECT;
+ Client::setState(STATE_WORLD_SELECT);
}
else
{
@@ -315,7 +315,7 @@ void LoginHandler::handleRegisterResponse(Net::MessageIn &msg)
errorMessage = _("Unknown error.");
break;
}
- state = STATE_LOGIN_ERROR;
+ Client::setState(STATE_LOGIN_ERROR);
}
}
@@ -342,9 +342,9 @@ void LoginHandler::disconnect()
{
accountServerConnection->disconnect();
- if (state == STATE_CONNECT_GAME)
+ if (Client::getState() == STATE_CONNECT_GAME)
{
- state = STATE_GAME;
+ Client::setState(STATE_GAME);
}
}
diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp
index a78afa8a..3a5d68a2 100644
--- a/src/net/manaserv/playerhandler.cpp
+++ b/src/net/manaserv/playerhandler.cpp
@@ -22,6 +22,7 @@
#include "net/manaserv/playerhandler.h"
#include "net/manaserv/beinghandler.h"
+#include "client.h"
#include "effectmanager.h"
#include "game.h"
#include "localplayer.h"
@@ -41,9 +42,6 @@
#include "net/manaserv/messageout.h"
#include "net/manaserv/protocol.h"
-/** @see in game.cpp */
-extern const int MILLISECONDS_IN_A_TICK;
-
/**
* Max. distance we are willing to scroll after a teleport;
* everything beyond will reset the port hard.