diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-04-01 14:13:11 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-04-01 14:13:11 -0600 |
commit | b987a2806dbcd87a23850901f6f0b86f0801086c (patch) | |
tree | e373f4869436f830c2cdeeeaf34a941560ded3fe /src/net/ea | |
parent | 6ef22b50f3d0c2410af5bd2543bedc0b3d692f83 (diff) | |
download | mana-client-b987a2806dbcd87a23850901f6f0b86f0801086c.tar.gz mana-client-b987a2806dbcd87a23850901f6f0b86f0801086c.tar.bz2 mana-client-b987a2806dbcd87a23850901f6f0b86f0801086c.tar.xz mana-client-b987a2806dbcd87a23850901f6f0b86f0801086c.zip |
Create a few more handlers for eAthena
Map, chat, and admin have been finished (to the degree they handle all
existing cases).
Diffstat (limited to 'src/net/ea')
-rw-r--r-- | src/net/ea/chathandler.cpp | 79 | ||||
-rw-r--r-- | src/net/ea/chathandler.h | 28 | ||||
-rw-r--r-- | src/net/ea/maploginhandler.cpp | 78 | ||||
-rw-r--r-- | src/net/ea/maploginhandler.h | 35 | ||||
-rw-r--r-- | src/net/ea/playerhandler.cpp | 3 | ||||
-rw-r--r-- | src/net/ea/protocol.h | 6 |
6 files changed, 105 insertions, 124 deletions
diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp index 6aca58a3..3628784d 100644 --- a/src/net/ea/chathandler.cpp +++ b/src/net/ea/chathandler.cpp @@ -24,6 +24,7 @@ #include "net/ea/protocol.h" #include "net/messagein.h" +#include "net/messageout.h" #include "being.h" #include "beingmanager.h" @@ -34,13 +35,14 @@ #include "utils/gettext.h" #include "utils/stringutils.h" +#include "utils/strprintf.h" #include <string> -extern Being *player_node; - #define SERVER_NAME "Server" +ChatHandler *chatHandler; + ChatHandler::ChatHandler() { static const Uint16 _messages[] = { @@ -49,11 +51,11 @@ ChatHandler::ChatHandler() SMSG_WHISPER, SMSG_WHISPER_RESPONSE, SMSG_GM_CHAT, - SMSG_WHO_ANSWER, 0x10c, // MVP 0 }; handledMessages = _messages; + chatHandler = this; } void ChatHandler::handleMessage(MessageIn &msg) @@ -159,11 +161,6 @@ void ChatHandler::handleMessage(MessageIn &msg) break; } - case SMSG_WHO_ANSWER: - localChatTab->chatLog("Online users: " + toString(msg.readInt32()), - BY_SERVER); - break; - case 0x010c: // Display MVP player msg.readInt32(); // id @@ -171,3 +168,69 @@ void ChatHandler::handleMessage(MessageIn &msg) break; } } + +void ChatHandler::talk(const std::string &text) +{ + std::string mes = player_node->getName() + " : " + text; + + MessageOut outMsg(CMSG_CHAT_MESSAGE); + // Added + 1 in order to let eAthena parse admin commands correctly + outMsg.writeInt16(text.length() + 4 + 1); + outMsg.writeString(text, text.length() + 1); +} + +void ChatHandler::me(const std::string &text) +{ + std::string action = strprintf("*%s*", text.c_str()); + + talk(text); +} + +void ChatHandler::privateMessage(const std::string &recipient, + const std::string &text) +{ + MessageOut outMsg(CMSG_CHAT_WHISPER); + outMsg.writeInt16(text.length() + 28); + outMsg.writeString(recipient, 24); + outMsg.writeString(text, text.length()); +} + +void ChatHandler::channelList() +{ + // TODO +} + +void ChatHandler::enterChannel(int channelId, const std::string &password) +{ + // TODO +} + +void ChatHandler::quitChannel(int channelId) +{ + // TODO +} + +void ChatHandler::sendToChannel(int channelId, const std::string &text) +{ + // TODO +} + +void ChatHandler::userList(int channelId) +{ + // TODO +} + +void ChatHandler::setChannelTopic(int channelId, const std::string &text) +{ + // TODO +} + +void ChatHandler::setUserMode(int channelId, const std::string &name, int mode) +{ + // TODO +} + +void ChatHandler::kickUser(int channelId, const std::string &name) +{ + // TODO +} diff --git a/src/net/ea/chathandler.h b/src/net/ea/chathandler.h index 93e3e272..99c580dd 100644 --- a/src/net/ea/chathandler.h +++ b/src/net/ea/chathandler.h @@ -23,13 +23,39 @@ #define NET_EA_CHATHANDLER_H #include "net/messagehandler.h" +#include "net/net.h" -class ChatHandler : public MessageHandler +class ChatHandler : public MessageHandler, public Net::ChatHandler { public: ChatHandler(); virtual void handleMessage(MessageIn &msg); + + virtual void talk(const std::string &text); + + virtual void me(const std::string &text); + + virtual void privateMessage(const std::string &recipient, + const std::string &text); + + virtual void channelList(); + + virtual void enterChannel(int channelId, const std::string &password); + + virtual void quitChannel(int channelId); + + virtual void sendToChannel(int channelId, const std::string &text); + + virtual void userList(int channelId); + + virtual void setChannelTopic(int channelId, const std::string &text); + + virtual void setUserMode(int channelId, const std::string &name, int mode); + + virtual void kickUser(int channelId, const std::string &name); }; +extern ChatHandler *chatHandler; + #endif // NET_EA_CHATHANDLER_H diff --git a/src/net/ea/maploginhandler.cpp b/src/net/ea/maploginhandler.cpp deleted file mode 100644 index 78f021b0..00000000 --- a/src/net/ea/maploginhandler.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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/maploginhandler.h" - -#include "net/ea/protocol.h" - -#include "net/messagein.h" - -#include "localplayer.h" -#include "log.h" -#include "main.h" - -#include "utils/gettext.h" - -MapLoginHandler::MapLoginHandler() -{ - static const Uint16 _messages[] = { - SMSG_CONNECTION_PROBLEM, - SMSG_LOGIN_SUCCESS, - 0 - }; - handledMessages = _messages; -} - -void MapLoginHandler::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 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); - msg.skip(2); // unknown - logger->log("Protocol: Player start position: (%d, %d), Direction: %d", - player_node->mX, player_node->mY, direction); - state = STATE_GAME; - break; - } -} diff --git a/src/net/ea/maploginhandler.h b/src/net/ea/maploginhandler.h deleted file mode 100644 index 33ac9ee7..00000000 --- a/src/net/ea/maploginhandler.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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_MAPLOGINHANDLER_H -#define NET_EA_MAPLOGINHANDLER_H - -#include "net/messagehandler.h" - -class MapLoginHandler : public MessageHandler -{ - public: - MapLoginHandler(); - - virtual void handleMessage(MessageIn &msg); -}; - -#endif // NET_EA_MAPLOGINHANDLER_H diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index cb3ed089..f0876a6e 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -199,8 +199,7 @@ void PlayerHandler::handleMessage(MessageIn &msg) // Switch the actual map, deleting the previous one if necessary mapPath = mapPath.substr(0, mapPath.rfind(".")); - if (engine->changeMap(mapPath)) - MessageOut outMsg(CMSG_MAP_LOADED); + engine->changeMap(mapPath); float scrollOffsetX = 0.0f; float scrollOffsetY = 0.0f; diff --git a/src/net/ea/protocol.h b/src/net/ea/protocol.h index 8a4d6135..5a2260e6 100644 --- a/src/net/ea/protocol.h +++ b/src/net/ea/protocol.h @@ -121,6 +121,7 @@ static const int STORAGE_OFFSET = 1; * Packets from client to server * **********************************/ #define CMSG_CLIENT_PING 0x007e /**< Send to server with tick */ +#define CMSG_CLIENT_QUIT 0x018A #define CMSG_TRADE_RESPONSE 0x00e6 #define CMSG_ITEM_PICKUP 0x009f #define CMSG_MAP_LOADED 0x007d @@ -161,6 +162,11 @@ static const int STORAGE_OFFSET = 1; #define CSMG_MOVE_FROM_STORAGE 0x00f5 /** Remove item from storage */ #define CMSG_CLOSE_STORAGE 0x00f7 /** Request storage close */ +#define CMSG_ADMIN_ANNOUNCE 0x0099 +#define CMSG_ADMIN_LOCAL_ANNOUNCE 0x019C +#define CMSG_ADMIN_HIDE 0x019D +#define CMSG_ADMIN_KICK 0x00CC + /** Encodes coords and direction in 3 bytes data */ void set_coordinates(char *data, unsigned short x, unsigned short y, unsigned char direction); |