summaryrefslogtreecommitdiff
path: root/src/net/ea
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/ea')
-rw-r--r--src/net/ea/charserverhandler.cpp46
-rw-r--r--src/net/ea/charserverhandler.h8
-rw-r--r--src/net/ea/chathandler.cpp2
-rw-r--r--src/net/ea/generalhandler.cpp164
-rw-r--r--src/net/ea/generalhandler.h69
-rw-r--r--src/net/ea/loginhandler.cpp77
-rw-r--r--src/net/ea/loginhandler.h26
-rw-r--r--src/net/ea/logouthandler.cpp66
-rw-r--r--src/net/ea/logouthandler.h47
-rw-r--r--src/net/ea/maphandler.cpp23
10 files changed, 449 insertions, 79 deletions
diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp
index 377cd2dd..0fcc2cb0 100644
--- a/src/net/ea/charserverhandler.cpp
+++ b/src/net/ea/charserverhandler.cpp
@@ -21,6 +21,7 @@
#include "net/ea/charserverhandler.h"
+#include "net/ea/network.h"
#include "net/ea/protocol.h"
#include "net/messagein.h"
@@ -45,7 +46,6 @@ CharServerHandler::CharServerHandler():
mCharCreateDialog(0)
{
static const Uint16 _messages[] = {
- SMSG_CONNECTION_PROBLEM,
0x006b,
0x006c,
0x006d,
@@ -68,33 +68,6 @@ void CharServerHandler::handleMessage(MessageIn &msg)
msg.getId(), msg.getLength());
switch (msg.getId())
{
- case SMSG_CONNECTION_PROBLEM:
- code = msg.readInt8();
- logger->log("Connection problem: %i", code);
-
- switch (code) {
- case 0:
- errorMessage = _("Authentication failed");
- break;
- case 1:
- errorMessage = _("Map server(s) offline");
- break;
- case 2:
- errorMessage = _("This account is already logged in");
- break;
- case 3:
- errorMessage = _("Speed hack detected");
- break;
- case 8:
- errorMessage = _("Duplicated login");
- break;
- default:
- errorMessage = _("Unknown connection error");
- break;
- }
- state = STATE_ERROR;
- break;
-
case 0x006b:
msg.skip(2); // Length word
flags = msg.readInt32(); // Aethyra extensions flags
@@ -259,6 +232,23 @@ void CharServerHandler::setCharCreateDialog(CharCreateDialog *window)
mCharCreateDialog->setFixedGender(true);
}
+void CharServerHandler::connect(LoginData *loginData)
+{
+ mLoginData = loginData;
+
+ MessageOut outMsg(0x0065);
+ outMsg.writeInt32(loginData->account_ID);
+ outMsg.writeInt32(loginData->session_ID1);
+ outMsg.writeInt32(loginData->session_ID2);
+ // [Fate] The next word is unused by the old char server, so we squeeze in
+ // tmw client version information
+ outMsg.writeInt16(CLIENT_PROTOCOL_VERSION);
+ outMsg.writeInt8(loginData->sex);
+
+ // We get 4 useless bytes before the real answer comes in (what are these?)
+ mNetwork->skip(4);
+}
+
void CharServerHandler::chooseCharacter(int slot, LocalPlayer* character)
{
MessageOut outMsg(CMSG_CHAR_SELECT);
diff --git a/src/net/ea/charserverhandler.h b/src/net/ea/charserverhandler.h
index 48392ac4..3ebac16e 100644
--- a/src/net/ea/charserverhandler.h
+++ b/src/net/ea/charserverhandler.h
@@ -25,9 +25,6 @@
#include "net/messagehandler.h"
#include "net/charhandler.h"
-#include "lockedarray.h"
-
-class LocalPlayer;
class LoginData;
namespace EAthena {
@@ -45,9 +42,6 @@ class CharServerHandler : public MessageHandler, public Net::CharHandler
void setCharInfo(LockedArray<LocalPlayer*> *charInfo)
{ mCharInfo = charInfo; }
- void setLoginData(LoginData *loginData)
- { mLoginData = loginData; }
-
/**
* Sets the character create dialog. The handler will clean up this
* dialog when a new character is succesfully created, and will unlock
@@ -55,6 +49,8 @@ class CharServerHandler : public MessageHandler, public Net::CharHandler
*/
void setCharCreateDialog(CharCreateDialog *window);
+ void connect(LoginData *loginData);
+
void chooseCharacter(int slot, LocalPlayer* character);
void newCharacter(const std::string &name, int slot, bool gender,
diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp
index 13593ed1..997881f8 100644
--- a/src/net/ea/chathandler.cpp
+++ b/src/net/ea/chathandler.cpp
@@ -148,7 +148,7 @@ void ChatHandler::handleMessage(MessageIn &msg)
if (msg.getId() == SMSG_PLAYER_CHAT)
{
- localChatTab->chatLog(chatMsg, BY_PLAYER);
+ if (localChatTab) localChatTab->chatLog(chatMsg, BY_PLAYER);
if (pos != std::string::npos)
chatMsg.erase(0, pos + 3);
diff --git a/src/net/ea/generalhandler.cpp b/src/net/ea/generalhandler.cpp
new file mode 100644
index 00000000..5d204ab5
--- /dev/null
+++ b/src/net/ea/generalhandler.cpp
@@ -0,0 +1,164 @@
+/*
+ * The Mana World
+ * Copyright (C) 2009 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "net/ea/generalhandler.h"
+
+#include "net/ea/network.h"
+#include "net/ea/protocol.h"
+
+#include "net/ea/adminhandler.h"
+#include "net/ea/beinghandler.h"
+#include "net/ea/buysellhandler.h"
+#include "net/ea/chathandler.h"
+#include "net/ea/charserverhandler.h"
+#include "net/ea/equipmenthandler.h"
+#include "net/ea/inventoryhandler.h"
+#include "net/ea/itemhandler.h"
+#include "net/ea/loginhandler.h"
+#include "net/ea/logouthandler.h"
+#include "net/ea/maphandler.h"
+#include "net/ea/npchandler.h"
+#include "net/ea/playerhandler.h"
+#include "net/ea/partyhandler.h"
+#include "net/ea/tradehandler.h"
+#include "net/ea/skillhandler.h"
+
+#include "net/ea/gui/partytab.h"
+
+#include "net/messagein.h"
+#include "net/messageout.h"
+
+#include "configuration.h"
+#include "log.h"
+#include "main.h"
+
+#include "utils/gettext.h"
+
+Net::GeneralHandler *generalHandler;
+
+namespace EAthena {
+
+GeneralHandler::GeneralHandler():
+ mAdminHandler(new AdminHandler),
+ mBeingHandler(new BeingHandler(config.getValue("EnableSync", 0) == 1)),
+ mBuySellHandler(new BuySellHandler),
+ mCharHandler(new CharServerHandler),
+ mChatHandler(new ChatHandler),
+ mEquipmentHandler(new EquipmentHandler),
+ mInventoryHandler(new InventoryHandler),
+ mItemHandler(new ItemHandler),
+ mLoginHandler(new LoginHandler),
+ mLogoutHandler(new LogoutHandler),
+ mMapHandler(new MapHandler),
+ mNpcHandler(new NpcHandler),
+ mPartyHandler(new PartyHandler),
+ mPlayerHandler(new PlayerHandler),
+ mSkillHandler(new SkillHandler),
+ mTradeHandler(new TradeHandler)
+{
+ static const Uint16 _messages[] = {
+ SMSG_CONNECTION_PROBLEM,
+ 0
+ };
+ handledMessages = _messages;
+ generalHandler = this;
+}
+
+void GeneralHandler::handleMessage(MessageIn &msg)
+{
+ int code;
+ unsigned char direction;
+
+ switch (msg.getId())
+ {
+ case SMSG_CONNECTION_PROBLEM:
+ code = msg.readInt8();
+ logger->log("Connection problem: %i", code);
+
+ switch (code) {
+ case 0:
+ errorMessage = _("Authentication failed");
+ break;
+ case 1:
+ errorMessage = _("No servers available");
+ break;
+ case 2:
+ errorMessage = _("This account is already logged in");
+ break;
+ case 3:
+ errorMessage = _("Speed hack detected");
+ break;
+ case 8:
+ errorMessage = _("Duplicated login");
+ break;
+ default:
+ errorMessage = _("Unknown connection error");
+ break;
+ }
+ state = STATE_ERROR;
+ break;
+ }
+}
+
+void GeneralHandler::load()
+{
+ mNetwork->registerHandler(mAdminHandler.get());
+ mNetwork->registerHandler(mBeingHandler.get());
+ mNetwork->registerHandler(mBuySellHandler.get());
+ mNetwork->registerHandler(mChatHandler.get());
+ mNetwork->registerHandler(mCharHandler.get());
+ mNetwork->registerHandler(mEquipmentHandler.get());
+ mNetwork->registerHandler(mInventoryHandler.get());
+ mNetwork->registerHandler(mItemHandler.get());
+ mNetwork->registerHandler(mLoginHandler.get());
+ mNetwork->registerHandler(mLogoutHandler.get());
+ mNetwork->registerHandler(mMapHandler.get());
+ mNetwork->registerHandler(mNpcHandler.get());
+ mNetwork->registerHandler(mPlayerHandler.get());
+ mNetwork->registerHandler(mSkillHandler.get());
+ mNetwork->registerHandler(mTradeHandler.get());
+ mNetwork->registerHandler(mPartyHandler.get());
+}
+
+void GeneralHandler::unload()
+{
+ mNetwork->clearHandlers();
+
+ delete partyTab;
+}
+
+void GeneralHandler::flushNetwork()
+{
+ mNetwork->flush();
+ mNetwork->dispatchMessages();
+}
+
+bool GeneralHandler::isNetworkConnected()
+{
+ return mNetwork->isConnected();
+}
+
+void GeneralHandler::guiWindowsLoaded()
+{
+ partyTab = new PartyTab();
+}
+
+} // namespace EAthena
diff --git a/src/net/ea/generalhandler.h b/src/net/ea/generalhandler.h
new file mode 100644
index 00000000..3e2a6707
--- /dev/null
+++ b/src/net/ea/generalhandler.h
@@ -0,0 +1,69 @@
+/*
+ * The Mana World
+ * Copyright (C) 2009 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef NET_EA_GENERALHANDLER_H
+#define NET_EA_GENERALHANDLER_H
+
+#include "net/generalhandler.h"
+#include "net/messagehandler.h"
+#include "net/net.h"
+
+namespace EAthena {
+
+class GeneralHandler : public MessageHandler, public Net::GeneralHandler
+{
+ public:
+ GeneralHandler();
+
+ void handleMessage(MessageIn &msg);
+
+ void load();
+
+ void unload();
+
+ void flushNetwork();
+
+ bool isNetworkConnected();
+
+ void guiWindowsLoaded();
+
+ protected:
+ MessageHandlerPtr mAdminHandler;
+ MessageHandlerPtr mBeingHandler;
+ MessageHandlerPtr mBuySellHandler;
+ MessageHandlerPtr mCharHandler;
+ MessageHandlerPtr mChatHandler;
+ MessageHandlerPtr mEquipmentHandler;
+ MessageHandlerPtr mInventoryHandler;
+ MessageHandlerPtr mItemHandler;
+ MessageHandlerPtr mLoginHandler;
+ MessageHandlerPtr mLogoutHandler;
+ MessageHandlerPtr mMapHandler;
+ MessageHandlerPtr mNpcHandler;
+ MessageHandlerPtr mPartyHandler;
+ MessageHandlerPtr mPlayerHandler;
+ MessageHandlerPtr mSkillHandler;
+ MessageHandlerPtr mTradeHandler;
+};
+
+} // namespace EAthena
+
+#endif // NET_EA_GENERALHANDLER_H
diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp
index 06bdb4bc..1031ee05 100644
--- a/src/net/ea/loginhandler.cpp
+++ b/src/net/ea/loginhandler.cpp
@@ -24,6 +24,7 @@
#include "net/ea/protocol.h"
#include "net/messagein.h"
+#include "net/messageout.h"
#include "log.h"
#include "logindata.h"
@@ -36,16 +37,20 @@
extern SERVER_INFO **server_info;
+Net::LoginHandler *loginHandler;
+
+namespace EAthena {
+
LoginHandler::LoginHandler()
{
static const Uint16 _messages[] = {
- SMSG_CONNECTION_PROBLEM,
SMSG_UPDATE_HOST,
0x0069,
0x006a,
0
};
handledMessages = _messages;
+ loginHandler = this;
}
void LoginHandler::handleMessage(MessageIn &msg)
@@ -54,27 +59,6 @@ void LoginHandler::handleMessage(MessageIn &msg)
switch (msg.getId())
{
- case SMSG_CONNECTION_PROBLEM:
- code = msg.readInt8();
- logger->log("Connection problem: %i", code);
-
- switch (code) {
- case 0:
- errorMessage = _("Authentication failed");
- break;
- case 1:
- errorMessage = _("No servers available");
- break;
- case 2:
- errorMessage = _("This account is already logged in");
- break;
- default:
- errorMessage = _("Unknown connection error");
- break;
- }
- state = STATE_ERROR;
- break;
-
case SMSG_UPDATE_HOST:
int len;
@@ -158,3 +142,52 @@ void LoginHandler::handleMessage(MessageIn &msg)
break;
}
}
+
+void LoginHandler::loginAccount(LoginData *loginData)
+{
+ mLoginData = loginData;
+ MessageOut outMsg(0x0064);
+ outMsg.writeInt32(0); // client version
+ outMsg.writeString(loginData->username, 24);
+ outMsg.writeString(loginData->password, 24);
+
+ /*
+ * eAthena calls the last byte "client version 2", but it isn't used at
+ * at all. We're retasking it, with bit 0 to indicate whether the client
+ * can handle the 0x63 "update host" packet. Clients prior to 0.0.25 send
+ * 0 here.
+ */
+ outMsg.writeInt8(0x01);
+}
+
+void LoginHandler::changeEmail(const std::string &email)
+{
+ // TODO
+}
+
+void LoginHandler::changePassword(const std::string &username,
+ const std::string &oldPassword,
+ const std::string &newPassword)
+{
+ // TODO
+}
+
+void LoginHandler::chooseServer(int server)
+{
+ // TODO
+}
+
+void LoginHandler::registerAccount(const std::string &username,
+ const std::string &password,
+ const std::string &email = "")
+{
+ // TODO
+}
+
+void LoginHandler::unregisterAccount(const std::string &username,
+ const std::string &password)
+{
+ // TODO
+}
+
+} // namespace EAthena
diff --git a/src/net/ea/loginhandler.h b/src/net/ea/loginhandler.h
index 9afaab23..cdc59e4a 100644
--- a/src/net/ea/loginhandler.h
+++ b/src/net/ea/loginhandler.h
@@ -22,24 +22,44 @@
#ifndef NET_EA_LOGINHANDLER_H
#define NET_EA_LOGINHANDLER_H
+#include "net/loginhandler.h"
#include "net/messagehandler.h"
#include <string>
struct LoginData;
-class LoginHandler : public MessageHandler
+namespace EAthena {
+
+class LoginHandler : public MessageHandler, public Net::LoginHandler
{
public:
LoginHandler();
- virtual void handleMessage(MessageIn &msg);
+ void handleMessage(MessageIn &msg);
+
+ void loginAccount(LoginData *loginData);
+
+ void changeEmail(const std::string &email);
+
+ void changePassword(const std::string &username,
+ const std::string &oldPassword,
+ const std::string &newPassword);
- void setLoginData(LoginData *loginData) { mLoginData = loginData; }
+ void chooseServer(int server);
+
+ void registerAccount(const std::string &username,
+ const std::string &password,
+ const std::string &email);
+
+ void unregisterAccount(const std::string &username,
+ const std::string &password);
private:
LoginData *mLoginData;
std::string mUpdateHost;
};
+} // namespace EAthena
+
#endif // NET_EA_LOGINHANDLER_H
diff --git a/src/net/ea/logouthandler.cpp b/src/net/ea/logouthandler.cpp
new file mode 100644
index 00000000..19659a2f
--- /dev/null
+++ b/src/net/ea/logouthandler.cpp
@@ -0,0 +1,66 @@
+/*
+ * The Mana World
+ * Copyright (C) 2004 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "net/ea/logouthandler.h"
+
+#include "net/ea/protocol.h"
+
+#include "net/messagein.h"
+#include "net/messageout.h"
+
+#include "log.h"
+#include "logindata.h"
+#include "main.h"
+#include "serverinfo.h"
+
+#include "utils/gettext.h"
+#include "utils/strprintf.h"
+#include "utils/stringutils.h"
+
+Net::LogoutHandler *logoutHandler;
+
+namespace EAthena {
+
+LogoutHandler::LogoutHandler()
+{
+ static const Uint16 _messages[] = {
+ 0
+ };
+ handledMessages = _messages;
+ logoutHandler = this;
+}
+
+void LogoutHandler::handleMessage(MessageIn &msg)
+{
+}
+
+void LogoutHandler::setScenario(unsigned short scenario,
+ std::string *passToken)
+{
+ // TODO
+}
+
+void LogoutHandler::reset()
+{
+ // TODO
+}
+
+} // namespace EAthena
diff --git a/src/net/ea/logouthandler.h b/src/net/ea/logouthandler.h
new file mode 100644
index 00000000..0d118ab0
--- /dev/null
+++ b/src/net/ea/logouthandler.h
@@ -0,0 +1,47 @@
+/*
+ * The Mana World
+ * Copyright (C) 2004 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef NET_EA_LOGOUTHANDLER_H
+#define NET_EA_LOGOUTHANDLER_H
+
+#include "net/logouthandler.h"
+#include "net/messagehandler.h"
+
+#include <string>
+
+namespace EAthena {
+
+class LogoutHandler : public MessageHandler, public Net::LogoutHandler
+{
+ public:
+ LogoutHandler();
+
+ void handleMessage(MessageIn &msg);
+
+ void setScenario(unsigned short scenario,
+ std::string *passToken = NULL);
+
+ void reset();
+};
+
+} // namespace EAthena
+
+#endif // NET_EA_LOGOUTHANDLER_H
diff --git a/src/net/ea/maphandler.cpp b/src/net/ea/maphandler.cpp
index 6912176f..6fd27755 100644
--- a/src/net/ea/maphandler.cpp
+++ b/src/net/ea/maphandler.cpp
@@ -21,6 +21,7 @@
#include "net/ea/maphandler.h"
+#include "net/ea/network.h"
#include "net/ea/protocol.h"
#include "net/messagein.h"
@@ -42,7 +43,6 @@ namespace EAthena {
MapHandler::MapHandler()
{
static const Uint16 _messages[] = {
- SMSG_CONNECTION_PROBLEM,
SMSG_LOGIN_SUCCESS,
SMSG_SERVER_PING,
SMSG_WHO_ANSWER,
@@ -59,24 +59,6 @@ void MapHandler::handleMessage(MessageIn &msg)
switch (msg.getId())
{
- case SMSG_CONNECTION_PROBLEM:
- code = msg.readInt8();
- logger->log("Connection problem: %i", code);
-
- switch (code) {
- case 0:
- errorMessage = _("Authentication failed");
- break;
- case 2:
- errorMessage = _("This account is already logged in");
- break;
- default:
- errorMessage = _("Unknown connection error");
- break;
- }
- state = STATE_ERROR;
- break;
-
case SMSG_LOGIN_SUCCESS:
msg.readInt32(); // server tick
msg.readCoordinates(player_node->mX, player_node->mY, direction);
@@ -107,6 +89,9 @@ void MapHandler::connect(LoginData *loginData)
outMsg.writeInt32(loginData->session_ID1);
outMsg.writeInt32(loginData->session_ID2);
outMsg.writeInt8(loginData->sex);
+
+ // We get 4 useless bytes before the real answer comes in (what are these?)
+ mNetwork->skip(4);
}
void MapHandler::mapLoaded(const std::string &mapName)