diff options
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/logindata.h | 4 | ||||
-rw-r--r-- | src/net/manaserv/loginhandler.cpp | 26 | ||||
-rw-r--r-- | src/net/manaserv/loginhandler.h | 4 | ||||
-rw-r--r-- | src/net/manaserv/manaserv_protocol.h | 2 | ||||
-rw-r--r-- | src/net/manaserv/playerhandler.cpp | 8 | ||||
-rw-r--r-- | src/net/manaserv/playerhandler.h | 2 | ||||
-rw-r--r-- | src/net/playerhandler.h | 8 | ||||
-rw-r--r-- | src/net/tmwa/playerhandler.cpp | 6 | ||||
-rw-r--r-- | src/net/tmwa/playerhandler.h | 2 |
9 files changed, 58 insertions, 4 deletions
diff --git a/src/net/logindata.h b/src/net/logindata.h index 4d8fc043..b842bdfd 100644 --- a/src/net/logindata.h +++ b/src/net/logindata.h @@ -1,7 +1,7 @@ /* * The Mana Client * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2009-2011 The Mana Developers * * This file is part of The Mana Client. * @@ -36,6 +36,7 @@ public: std::string username; std::string password; + std::string randomSeed; std::string newPassword; std::string updateHost; @@ -61,6 +62,7 @@ public: { username.clear(); password.clear(); + randomSeed.clear(); newPassword.clear(); updateHost.clear(); email.clear(); diff --git a/src/net/manaserv/loginhandler.cpp b/src/net/manaserv/loginhandler.cpp index 2f802e21..f06c3262 100644 --- a/src/net/manaserv/loginhandler.cpp +++ b/src/net/manaserv/loginhandler.cpp @@ -44,6 +44,7 @@ extern std::string netToken; LoginHandler::LoginHandler() { static const Uint16 _messages[] = { + APMSG_LOGIN_RNDTRGR_RESPONSE, APMSG_LOGIN_RESPONSE, APMSG_REGISTER_RESPONSE, APMSG_RECONNECT_RESPONSE, @@ -62,6 +63,10 @@ void LoginHandler::handleMessage(Net::MessageIn &msg) { switch (msg.getId()) { + case APMSG_LOGIN_RNDTRGR_RESPONSE: + handleLoginRandomResponse(msg); + break; + case APMSG_LOGIN_RESPONSE: handleLoginResponse(msg); break; @@ -245,6 +250,12 @@ void LoginHandler::handleMessage(Net::MessageIn &msg) } } +void LoginHandler::handleLoginRandomResponse(Net::MessageIn &msg) +{ + mLoginData->randomSeed = msg.readString(); + loginAccountContinue(); +} + void LoginHandler::handleLoginResponse(Net::MessageIn &msg) { const int errMsg = msg.readInt8(); @@ -385,14 +396,25 @@ unsigned int LoginHandler::getMaxUserNameLength() const void LoginHandler::loginAccount(LoginData *loginData) { mLoginData = loginData; + mTmpPassword = loginData->password; + + MessageOut msg(PAMSG_LOGIN_RNDTRGR); + msg.writeString(mLoginData->username); + accountServerConnection->send(msg); +} + +void LoginHandler::loginAccountContinue() +{ MessageOut msg(PAMSG_LOGIN); msg.writeInt32(PROTOCOL_VERSION); // client version - msg.writeString(loginData->username); - msg.writeString(sha256(loginData->username + loginData->password)); + msg.writeString(mLoginData->username); + + msg.writeString(sha256(sha256(sha256(mLoginData->username + mTmpPassword)) + mLoginData->randomSeed)); accountServerConnection->send(msg); + mTmpPassword = ""; } void LoginHandler::logout() diff --git a/src/net/manaserv/loginhandler.h b/src/net/manaserv/loginhandler.h index 2062dcb5..294b99ac 100644 --- a/src/net/manaserv/loginhandler.h +++ b/src/net/manaserv/loginhandler.h @@ -77,12 +77,16 @@ class LoginHandler : public MessageHandler, public Net::LoginHandler void reconnect(); private: + void handleLoginRandomResponse(Net::MessageIn &msg); void handleLoginResponse(Net::MessageIn &msg); void handleRegisterResponse(Net::MessageIn &msg); void readServerInfo(Net::MessageIn &msg); + void loginAccountContinue(); + LoginData *mLoginData; + std::string mTmpPassword; unsigned int mMinUserNameLength; unsigned int mMaxUserNameLength; }; diff --git a/src/net/manaserv/manaserv_protocol.h b/src/net/manaserv/manaserv_protocol.h index cd24d838..2c790d26 100644 --- a/src/net/manaserv/manaserv_protocol.h +++ b/src/net/manaserv/manaserv_protocol.h @@ -57,6 +57,8 @@ enum { APMSG_LOGIN_RESPONSE = 0x0012, // B error, S updatehost, S Client data URL, B Character slots PAMSG_LOGOUT = 0x0013, // - APMSG_LOGOUT_RESPONSE = 0x0014, // B error + PAMSG_LOGIN_RNDTRGR = 0x0015, // S username + APMSG_LOGIN_RNDTRGR_RESPONSE = 0x0016, // S random seed PAMSG_CHAR_CREATE = 0x0020, // S name, B hair style, B hair color, B gender, B slot, {W stats}* APMSG_CHAR_CREATE_RESPONSE = 0x0021, // B error PAMSG_CHAR_DELETE = 0x0022, // B slot diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp index a114da3d..d7c3dab6 100644 --- a/src/net/manaserv/playerhandler.cpp +++ b/src/net/manaserv/playerhandler.cpp @@ -442,4 +442,12 @@ Vector PlayerHandler::getPixelsPerTickMoveSpeed(const Vector &speed, Map *map) return speedInTicks; } +int PlayerHandler::getKeyboardMoveDelay(const Vector& speed) +{ + int maxSpeed = std::max(speed.x, speed.y); + if (maxSpeed <= 0) + maxSpeed = 2; + return 1000 / maxSpeed; +} + } // namespace ManaServ diff --git a/src/net/manaserv/playerhandler.h b/src/net/manaserv/playerhandler.h index 3e3f8aad..0edb4354 100644 --- a/src/net/manaserv/playerhandler.h +++ b/src/net/manaserv/playerhandler.h @@ -69,6 +69,8 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler Vector getPixelsPerTickMoveSpeed(const Vector &speed, Map *map = 0); + int getKeyboardMoveDelay(const Vector& speed); + bool usePixelPrecision() { return true; } diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h index f9396caf..b52b6315 100644 --- a/src/net/playerhandler.h +++ b/src/net/playerhandler.h @@ -71,12 +71,18 @@ class PlayerHandler virtual Vector getDefaultMoveSpeed() const = 0; /** - * Convert the original speed in pixel per tick for internal use. + * Convert the original server-dependant speed for internal use. */ virtual Vector getPixelsPerTickMoveSpeed(const Vector &speed, Map *map = 0) = 0; /** + * Convert the original speed into the keyboard move delay. + * The delay is set in milliseconds per tiles. + */ + virtual int getKeyboardMoveDelay(const Vector& speed) = 0; + + /** * Tells whether the client has to use pixel paths. * Return false when tiles-center positions only are to be used. */ diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index f30baecd..dd228f11 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -22,6 +22,7 @@ #include "net/tmwa/playerhandler.h" #include "net/tmwa/beinghandler.h" +#include "client.h" #include "configuration.h" #include "game.h" #include "localplayer.h" @@ -661,4 +662,9 @@ Vector PlayerHandler::getPixelsPerTickMoveSpeed(const Vector &speed, Map *map) return speedInTicks; } +int PlayerHandler::getKeyboardMoveDelay(const Vector& speed) +{ + return std::min(speed.x, speed.y) * MILLISECONDS_IN_A_TICK; +} + } // namespace TmwAthena diff --git a/src/net/tmwa/playerhandler.h b/src/net/tmwa/playerhandler.h index 63812f47..3e22be22 100644 --- a/src/net/tmwa/playerhandler.h +++ b/src/net/tmwa/playerhandler.h @@ -62,6 +62,8 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler Vector getPixelsPerTickMoveSpeed(const Vector &speed, Map *map = 0); + int getKeyboardMoveDelay(const Vector& speed); + bool usePixelPrecision() { return false; } }; |