summaryrefslogtreecommitdiff
path: root/src/net/tmwa
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/tmwa')
-rw-r--r--src/net/tmwa/loginhandler.cpp100
-rw-r--r--src/net/tmwa/loginhandler.h4
-rw-r--r--src/net/tmwa/loginrecv.cpp130
-rw-r--r--src/net/tmwa/loginrecv.h39
4 files changed, 178 insertions, 95 deletions
diff --git a/src/net/tmwa/loginhandler.cpp b/src/net/tmwa/loginhandler.cpp
index c94a82327..880e951a9 100644
--- a/src/net/tmwa/loginhandler.cpp
+++ b/src/net/tmwa/loginhandler.cpp
@@ -27,6 +27,9 @@
#include "net/serverfeatures.h"
+#include "net/ea/loginrecv.h"
+
+#include "net/tmwa/loginrecv.h"
#include "net/tmwa/messageout.h"
#include "net/tmwa/network.h"
#include "net/tmwa/protocol.h"
@@ -42,11 +45,6 @@ namespace TmwAthena
extern ServerInfo charServer;
-enum ServerFlags
-{
- FLAG_REGISTRATION = 1
-};
-
LoginHandler::LoginHandler() :
MessageHandler(),
Ea::LoginHandler()
@@ -74,23 +72,23 @@ void LoginHandler::handleMessage(Net::MessageIn &msg)
switch (msg.getId())
{
case SMSG_CHAR_PASSWORD_RESPONSE:
- processCharPasswordResponse(msg);
+ LoginRecv::processCharPasswordResponse(msg);
break;
case SMSG_UPDATE_HOST:
- processUpdateHost(msg);
+ Ea::LoginRecv::processUpdateHost(msg);
break;
case SMSG_LOGIN_DATA:
- processLoginData(msg);
+ Ea::LoginRecv::processLoginData(msg);
break;
case SMSG_LOGIN_ERROR:
- processLoginError(msg);
+ Ea::LoginRecv::processLoginError(msg);
break;
case SMSG_SERVER_VERSION_RESPONSE:
- processServerVersion(msg);
+ LoginRecv::processServerVersion(msg);
break;
default:
@@ -114,7 +112,7 @@ bool LoginHandler::isConnected() const
if (!mNetwork)
return false;
- return mVersionResponse && mNetwork->isConnected();
+ return Ea::LoginRecv::mVersionResponse && mNetwork->isConnected();
}
void LoginHandler::disconnect()
@@ -170,50 +168,6 @@ void LoginHandler::requestUpdateHosts()
{
}
-void LoginHandler::processServerVersion(Net::MessageIn &msg)
-{
- const uint8_t b1 = msg.readUInt8("b1"); // -1
- const uint8_t b2 = msg.readUInt8("b2");
- const uint8_t b3 = msg.readUInt8("b3");
- msg.readUInt8("b4");
- if (b1 == 255)
- { // old TMWA
- const unsigned int options = msg.readInt32("options");
- mRegistrationEnabled = options & FLAG_REGISTRATION;
- serverVersion = 0;
- tmwServerVersion = 0;
- }
- else if (b1 >= 0x0d)
- { // new TMWA
- const unsigned int options = msg.readInt32("options");
- mRegistrationEnabled = options & FLAG_REGISTRATION;
- serverVersion = 0;
- tmwServerVersion = (b1 << 16) | (b2 << 8) | b3;
- }
- else
- { // eAthena
- const unsigned int options = msg.readInt32("options");
- mRegistrationEnabled = options & FLAG_REGISTRATION;
- serverVersion = 0;
- tmwServerVersion = 0;
- }
- if (serverVersion > 0)
- logger->log("Evol server version: %d", serverVersion);
- else if (tmwServerVersion > 0)
- logger->log("Tmw server version: x%06x", tmwServerVersion);
- else
- logger->log("Server without version");
-
- if (serverVersion < 5)
- {
- if (client->getState() != STATE_LOGIN)
- client->setState(STATE_LOGIN);
- }
-
- // Leave this last
- mVersionResponse = true;
-}
-
int LoginHandler::supportedOptionalActions() const
{
return Net::RegistrationOptions::SetGenderOnRegister;
@@ -223,42 +177,6 @@ void LoginHandler::sendVersion() const
{
}
-void LoginHandler::processCharPasswordResponse(Net::MessageIn &msg)
-{
- // 0: acc not found, 1: success, 2: password mismatch, 3: pass too short
- const uint8_t errMsg = msg.readUInt8("result code");
- // Successful pass change
- if (errMsg == 1)
- {
- client->setState(STATE_CHANGEPASSWORD_SUCCESS);
- }
- // pass change failed
- else
- {
- switch (errMsg)
- {
- case 0:
- errorMessage =
- // TRANSLATORS: error message
- _("Account was not found. Please re-login.");
- break;
- case 2:
- // TRANSLATORS: error message
- errorMessage = _("Old password incorrect.");
- break;
- case 3:
- // TRANSLATORS: error message
- errorMessage = _("New password too short.");
- break;
- default:
- // TRANSLATORS: error message
- errorMessage = _("Unknown error.");
- break;
- }
- client->setState(STATE_ACCOUNTCHANGE_ERROR);
- }
-}
-
void LoginHandler::ping() const
{
}
diff --git a/src/net/tmwa/loginhandler.h b/src/net/tmwa/loginhandler.h
index 9db07dee5..48a9e060e 100644
--- a/src/net/tmwa/loginhandler.h
+++ b/src/net/tmwa/loginhandler.h
@@ -69,10 +69,6 @@ class LoginHandler final : public MessageHandler, public Ea::LoginHandler
const std::string &restrict password,
const std::string &restrict email)
const override final;
-
- static void processServerVersion(Net::MessageIn &msg);
-
- static void processCharPasswordResponse(Net::MessageIn &msg);
};
} // namespace TmwAthena
diff --git a/src/net/tmwa/loginrecv.cpp b/src/net/tmwa/loginrecv.cpp
new file mode 100644
index 000000000..fb1a0eee7
--- /dev/null
+++ b/src/net/tmwa/loginrecv.cpp
@@ -0,0 +1,130 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2015 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "net/tmwa/loginrecv.h"
+
+#include "client.h"
+#include "logger.h"
+
+#include "net/serverfeatures.h"
+
+#include "net/ea/loginrecv.h"
+
+#include "net/tmwa/messageout.h"
+#include "net/tmwa/network.h"
+#include "net/tmwa/protocol.h"
+
+#include "utils/gettext.h"
+
+#include "debug.h"
+
+namespace TmwAthena
+{
+
+extern ServerInfo charServer;
+
+enum ServerFlags
+{
+ FLAG_REGISTRATION = 1
+};
+
+void LoginRecv::processServerVersion(Net::MessageIn &msg)
+{
+ const uint8_t b1 = msg.readUInt8("b1"); // -1
+ const uint8_t b2 = msg.readUInt8("b2");
+ const uint8_t b3 = msg.readUInt8("b3");
+ msg.readUInt8("b4");
+ if (b1 == 255)
+ { // old TMWA
+ const unsigned int options = msg.readInt32("options");
+ Ea::LoginRecv::mRegistrationEnabled = options & FLAG_REGISTRATION;
+ serverVersion = 0;
+ tmwServerVersion = 0;
+ }
+ else if (b1 >= 0x0d)
+ { // new TMWA
+ const unsigned int options = msg.readInt32("options");
+ Ea::LoginRecv::mRegistrationEnabled = options & FLAG_REGISTRATION;
+ serverVersion = 0;
+ tmwServerVersion = (b1 << 16) | (b2 << 8) | b3;
+ }
+ else
+ { // eAthena
+ const unsigned int options = msg.readInt32("options");
+ Ea::LoginRecv::mRegistrationEnabled = options & FLAG_REGISTRATION;
+ serverVersion = 0;
+ tmwServerVersion = 0;
+ }
+ if (serverVersion > 0)
+ logger->log("Evol server version: %d", serverVersion);
+ else if (tmwServerVersion > 0)
+ logger->log("Tmw server version: x%06x", tmwServerVersion);
+ else
+ logger->log("Server without version");
+
+ if (serverVersion < 5)
+ {
+ if (client->getState() != STATE_LOGIN)
+ client->setState(STATE_LOGIN);
+ }
+
+ // Leave this last
+ Ea::LoginRecv::mVersionResponse = true;
+}
+
+void LoginRecv::processCharPasswordResponse(Net::MessageIn &msg)
+{
+ // 0: acc not found, 1: success, 2: password mismatch, 3: pass too short
+ const uint8_t errMsg = msg.readUInt8("result code");
+ // Successful pass change
+ if (errMsg == 1)
+ {
+ client->setState(STATE_CHANGEPASSWORD_SUCCESS);
+ }
+ // pass change failed
+ else
+ {
+ switch (errMsg)
+ {
+ case 0:
+ errorMessage =
+ // TRANSLATORS: error message
+ _("Account was not found. Please re-login.");
+ break;
+ case 2:
+ // TRANSLATORS: error message
+ errorMessage = _("Old password incorrect.");
+ break;
+ case 3:
+ // TRANSLATORS: error message
+ errorMessage = _("New password too short.");
+ break;
+ default:
+ // TRANSLATORS: error message
+ errorMessage = _("Unknown error.");
+ break;
+ }
+ client->setState(STATE_ACCOUNTCHANGE_ERROR);
+ }
+}
+
+} // namespace TmwAthena
diff --git a/src/net/tmwa/loginrecv.h b/src/net/tmwa/loginrecv.h
new file mode 100644
index 000000000..0945a7066
--- /dev/null
+++ b/src/net/tmwa/loginrecv.h
@@ -0,0 +1,39 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2015 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NET_TMWA_LOGINRECV_H
+#define NET_TMWA_LOGINRECV_H
+
+#include "net/ea/loginhandler.h"
+
+#include "net/tmwa/messagehandler.h"
+
+namespace TmwAthena
+{
+ namespace LoginRecv
+ {
+ void processServerVersion(Net::MessageIn &msg);
+ void processCharPasswordResponse(Net::MessageIn &msg);
+ } // namespace LoginRecv
+} // namespace TmwAthena
+
+#endif // NET_TMWA_LOGINRECV_H