From bcc4695387d21f9629ab6f013aadbfe0d238aa6d Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Sun, 5 Apr 2009 21:50:02 -0600 Subject: Implement TMWServ's Admin-, Chat-, and MapHandlers --- src/net/tmwserv/adminhandler.cpp | 85 ++++++++++++++++++++++++++++++++++++++++ src/net/tmwserv/adminhandler.h | 57 +++++++++++++++++++++++++++ src/net/tmwserv/chathandler.cpp | 64 ++++++++++++++++++++++++++++++ src/net/tmwserv/chathandler.h | 31 ++++++++++++++- src/net/tmwserv/maphandler.cpp | 58 +++++++++++++++++++++++++++ src/net/tmwserv/maphandler.h | 47 ++++++++++++++++++++++ 6 files changed, 341 insertions(+), 1 deletion(-) create mode 100644 src/net/tmwserv/adminhandler.cpp create mode 100644 src/net/tmwserv/adminhandler.h create mode 100644 src/net/tmwserv/maphandler.cpp create mode 100644 src/net/tmwserv/maphandler.h (limited to 'src/net/tmwserv') diff --git a/src/net/tmwserv/adminhandler.cpp b/src/net/tmwserv/adminhandler.cpp new file mode 100644 index 00000000..e1e3b074 --- /dev/null +++ b/src/net/tmwserv/adminhandler.cpp @@ -0,0 +1,85 @@ +/* + * 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/tmwserv/adminhandler.h" + +#include "net/tmwserv/chatserver/chatserver.h" + +Net::AdminHandler *adminHandler; + +namespace TmwServ { + +AdminHandler::AdminHandler() +{ + adminHandler = this; +} + +void AdminHandler::announce(const std::string &text) +{ + Net::ChatServer::announce(text); +} + +void AdminHandler::localAnnounce(const std::string &text) +{ + // TODO +} + +void AdminHandler::hide(bool hide) +{ + // TODO +} + +void AdminHandler::kick(int playerId) +{ + // TODO +} + +void AdminHandler::kick(const std::string &name) +{ + // TODO +} + +void AdminHandler::ban(int playerId) +{ + // TODO +} + +void AdminHandler::ban(const std::string &name) +{ + // TODO +} + +void AdminHandler::unban(int playerId) +{ + // TODO +} + +void AdminHandler::unban(const std::string &name) +{ + // TODO +} + +void AdminHandler::mute(int playerId, int type, int limit) +{ + // TODO +} + +} // namespace TmwServ diff --git a/src/net/tmwserv/adminhandler.h b/src/net/tmwserv/adminhandler.h new file mode 100644 index 00000000..0b83dfce --- /dev/null +++ b/src/net/tmwserv/adminhandler.h @@ -0,0 +1,57 @@ +/* + * 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_TMWSERV_ADMINHANDLER_H +#define NET_TMWSERV_ADMINHANDLER_H + +#include "net/adminhandler.h" + +namespace TmwServ { + +class AdminHandler : public Net::AdminHandler +{ + public: + AdminHandler(); + + void announce(const std::string &text); + + void localAnnounce(const std::string &text); + + void hide(bool hide); + + void kick(int playerId); + + void kick(const std::string &name); + + void ban(int playerId); + + void ban(const std::string &name); + + void unban(int playerId); + + void unban(const std::string &name); + + void mute(int playerId, int type, int limit); +}; + +} // namespace TmwServ + +#endif diff --git a/src/net/tmwserv/chathandler.cpp b/src/net/tmwserv/chathandler.cpp index 1c537e30..febffa12 100644 --- a/src/net/tmwserv/chathandler.cpp +++ b/src/net/tmwserv/chathandler.cpp @@ -23,6 +23,10 @@ #include "net/tmwserv/protocol.h" +#include "net/tmwserv/chatserver/chatserver.h" + +#include "net/tmwserv/gameserver/player.h" + #include "net/messagein.h" #include "being.h" @@ -42,6 +46,10 @@ extern Being *player_node; +Net::ChatHandler *chatHandler; + +namespace TmwServ { + ChatHandler::ChatHandler() { static const Uint16 _messages[] = { @@ -283,3 +291,59 @@ void ChatHandler::handleChannelEvent(MessageIn &msg) } } +void ChatHandler::talk(const std::string &text) +{ + Net::GameServer::Player::say(text); +} + +void ChatHandler::me(const std::string &text) +{ + // TODO +} + +void ChatHandler::privateMessage(const std::string &recipient, const std::string &text) +{ + Net::ChatServer::privMsg(recipient, text); +} + +void ChatHandler::channelList() +{ + Net::ChatServer::getChannelList(); +} + +void ChatHandler::enterChannel(const std::string &channel, const std::string &password) +{ + Net::ChatServer::enterChannel(channel, password); +} + +void ChatHandler::quitChannel(int channelId) +{ + Net::ChatServer::quitChannel(channelId); +} + +void ChatHandler::sendToChannel(int channelId, const std::string &text) +{ + Net::ChatServer::chat(channelId, text); +} + +void ChatHandler::userList(const std::string &channel) +{ + Net::ChatServer::getUserList(channel); +} + +void ChatHandler::setChannelTopic(int channelId, const std::string &text) +{ + Net::ChatServer::setChannelTopic(channelId, text); +} + +void ChatHandler::setUserMode(int channelId, const std::string &name, int mode) +{ + Net::ChatServer::setUserMode(channelId, name, mode); +} + +void ChatHandler::kickUser(int channelId, const std::string &name) +{ + Net::ChatServer::kickUser(channelId, name); +} + +} // namespace TmwServ diff --git a/src/net/tmwserv/chathandler.h b/src/net/tmwserv/chathandler.h index f0604da8..05f5243d 100644 --- a/src/net/tmwserv/chathandler.h +++ b/src/net/tmwserv/chathandler.h @@ -22,9 +22,12 @@ #ifndef NET_TMWSERV_CHATHANDLER_H #define NET_TMWSERV_CHATHANDLER_H +#include "net/chathandler.h" #include "net/messagehandler.h" -class ChatHandler : public MessageHandler +namespace TmwServ { + +class ChatHandler : public MessageHandler, public Net::ChatHandler { public: ChatHandler(); @@ -33,6 +36,30 @@ class ChatHandler : public MessageHandler * Handle the given message appropriately. */ void handleMessage(MessageIn &msg); + + void talk(const std::string &text); + + void me(const std::string &text); + + void privateMessage(const std::string &recipient, + const std::string &text); + + void channelList(); + + void enterChannel(const std::string &channel, + const std::string &password); + + void quitChannel(int channelId); + + void sendToChannel(int channelId, const std::string &text); + + void userList(const std::string &channel); + + void setChannelTopic(int channelId, const std::string &text); + + void setUserMode(int channelId, const std::string &name, int mode); + + void kickUser(int channelId, const std::string &name); private: /** @@ -81,4 +108,6 @@ class ChatHandler : public MessageHandler void handleChannelEvent(MessageIn &msg); }; +} // namespace TmwServ + #endif diff --git a/src/net/tmwserv/maphandler.cpp b/src/net/tmwserv/maphandler.cpp new file mode 100644 index 00000000..bbdb873e --- /dev/null +++ b/src/net/tmwserv/maphandler.cpp @@ -0,0 +1,58 @@ +/* + * 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/tmwserv/maphandler.h" + +Net::MapHandler *mapHandler; + +namespace TmwServ { + +MapHandler::MapHandler() +{ + mapHandler = this; +} + +void MapHandler::connect(LoginData *loginData) +{ + // TODO +} + +void MapHandler::mapLoaded(const std::string &mapName) +{ + // TODO +} + +void MapHandler::who() +{ + // TODO +} + +void MapHandler::quit() +{ + // TODO +} + +void MapHandler::ping(int tick) +{ + // TODO +} + +} // namespace TmwServ diff --git a/src/net/tmwserv/maphandler.h b/src/net/tmwserv/maphandler.h new file mode 100644 index 00000000..649feda6 --- /dev/null +++ b/src/net/tmwserv/maphandler.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_TMWSERV_MAPHANDLER_H +#define NET_TMWSERV_MAPHANDLER_H + +#include "net/maphandler.h" + +namespace TmwServ { + +class MapHandler : public Net::MapHandler +{ + public: + MapHandler(); + + void connect(LoginData *loginData); + + void mapLoaded(const std::string &mapName); + + void who(); + + void quit(); + + void ping(int tick); +}; + +} // namespace TmwServ + +#endif -- cgit v1.2.3-70-g09d2