diff options
Diffstat (limited to 'src/net/manaserv/chatserver')
-rw-r--r-- | src/net/manaserv/chatserver/chatserver.cpp | 54 | ||||
-rw-r--r-- | src/net/manaserv/chatserver/chatserver.h | 44 | ||||
-rw-r--r-- | src/net/manaserv/chatserver/guild.cpp | 95 | ||||
-rw-r--r-- | src/net/manaserv/chatserver/guild.h | 67 | ||||
-rw-r--r-- | src/net/manaserv/chatserver/internal.cpp | 32 | ||||
-rw-r--r-- | src/net/manaserv/chatserver/internal.h | 35 | ||||
-rw-r--r-- | src/net/manaserv/chatserver/party.cpp | 79 | ||||
-rw-r--r-- | src/net/manaserv/chatserver/party.h | 61 |
8 files changed, 467 insertions, 0 deletions
diff --git a/src/net/manaserv/chatserver/chatserver.cpp b/src/net/manaserv/chatserver/chatserver.cpp new file mode 100644 index 00000000..f0f5faf2 --- /dev/null +++ b/src/net/manaserv/chatserver/chatserver.cpp @@ -0,0 +1,54 @@ +/* + * 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 "chatserver.h" + +#include "internal.h" + +#include "net/manaserv/connection.h" +#include "net/manaserv/protocol.h" + +#include "net/messageout.h" + +using Net::ChatServer::connection; + +void Net::ChatServer::connect(Net::Connection *connection, + const std::string &token) +{ + Net::ChatServer::connection = connection; + + MessageOut msg(PCMSG_CONNECT); + msg.writeString(token, 32); + connection->send(msg); +} + +void Net::ChatServer::logout() +{ + MessageOut msg(PCMSG_DISCONNECT); + connection->send(msg); +} + +void Net::ChatServer::announce(const std::string &text) +{ + MessageOut msg(PCMSG_ANNOUNCE); + msg.writeString(text); + connection->send(msg); +} diff --git a/src/net/manaserv/chatserver/chatserver.h b/src/net/manaserv/chatserver/chatserver.h new file mode 100644 index 00000000..18859a2c --- /dev/null +++ b/src/net/manaserv/chatserver/chatserver.h @@ -0,0 +1,44 @@ +/* + * 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_CHATSERVER_CHATSERVER_H +#define NET_CHATSERVER_CHATSERVER_H + +#include <iosfwd> + +namespace Net +{ + class Connection; + + namespace ChatServer + { + void connect(Net::Connection *connection, const std::string &token); + + void logout(); + + void announce(const std::string &text); + + void kickUser(short channel, const std::string &user); + + } +} + +#endif diff --git a/src/net/manaserv/chatserver/guild.cpp b/src/net/manaserv/chatserver/guild.cpp new file mode 100644 index 00000000..5973077e --- /dev/null +++ b/src/net/manaserv/chatserver/guild.cpp @@ -0,0 +1,95 @@ +/* + * 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 "guild.h" + +#include "internal.h" + +#include "net/manaserv/connection.h" +#include "net/manaserv/protocol.h" + +#include "net/messageout.h" + +#include "log.h" + +void Net::ChatServer::Guild::createGuild(const std::string &name) +{ + logger->log("Sending PCMSG_GUILD_CREATE"); + MessageOut msg(PCMSG_GUILD_CREATE); + + msg.writeString(name); + + Net::ChatServer::connection->send(msg); +} + +void Net::ChatServer::Guild::invitePlayer(const std::string &name, short guildId) +{ + logger->log("Sending PCMSG_GUILD_INVITE"); + MessageOut msg(PCMSG_GUILD_INVITE); + + msg.writeInt16(guildId); + msg.writeString(name); + + Net::ChatServer::connection->send(msg); +} + +void Net::ChatServer::Guild::acceptInvite(const std::string &name) +{ + logger->log("Sending PCMSG_GUILD_ACCEPT"); + MessageOut msg(PCMSG_GUILD_ACCEPT); + + msg.writeString(name); + + Net::ChatServer::connection->send(msg); +} + +void Net::ChatServer::Guild::getGuildMembers(short guildId) +{ + logger->log("Sending PCMSG_GUILD_GET_MEMBERS"); + MessageOut msg(PCMSG_GUILD_GET_MEMBERS); + + msg.writeInt16(guildId); + + Net::ChatServer::connection->send(msg); +} + +void Net::ChatServer::Guild::promoteMember(const std::string &name, + short guildId, short level) +{ + logger->log("Sending PCMSG_GUILD_PROMOTE_MEMBER"); + MessageOut msg(PCMSG_GUILD_PROMOTE_MEMBER); + + msg.writeInt16(guildId); + msg.writeString(name); + msg.writeInt8(level); + + Net::ChatServer::connection->send(msg); +} + +void Net::ChatServer::Guild::quitGuild(short guildId) +{ + logger->log("Sending PCMSG_GUILD_QUIT"); + MessageOut msg(PCMSG_GUILD_QUIT); + + msg.writeInt16(guildId); + + Net::ChatServer::connection->send(msg); +} diff --git a/src/net/manaserv/chatserver/guild.h b/src/net/manaserv/chatserver/guild.h new file mode 100644 index 00000000..2e9cf9a6 --- /dev/null +++ b/src/net/manaserv/chatserver/guild.h @@ -0,0 +1,67 @@ +/* + * 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_CHATSERVER_GUILD_H +#define NET_CHATSERVER_GUILD_H + +#include <iosfwd> + +namespace Net +{ + namespace ChatServer + { + namespace Guild + { + /** + * Create guild. + */ + void createGuild(const std::string &name); + + /** + * Invite a player to your guild. + */ + void invitePlayer(const std::string &name, short guildId); + + /** + * Accept an invite another player has sent to join their guild. + */ + void acceptInvite(const std::string &name); + + /** + * Get a list of members in a guild. + */ + void getGuildMembers(short guildId); + + /** + * Promote guild member + */ + void promoteMember(const std::string &name, short guildId, + short level); + + /** + * Quit guild. + */ + void quitGuild(short guildId); + } + } +} + +#endif diff --git a/src/net/manaserv/chatserver/internal.cpp b/src/net/manaserv/chatserver/internal.cpp new file mode 100644 index 00000000..52744804 --- /dev/null +++ b/src/net/manaserv/chatserver/internal.cpp @@ -0,0 +1,32 @@ +/* + * 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 "internal.h" + +namespace Net +{ + class Connection; + + namespace ChatServer + { + Connection *connection = 0; + } +} diff --git a/src/net/manaserv/chatserver/internal.h b/src/net/manaserv/chatserver/internal.h new file mode 100644 index 00000000..162d54fb --- /dev/null +++ b/src/net/manaserv/chatserver/internal.h @@ -0,0 +1,35 @@ +/* + * 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_CHATSERVER_INTERNAL_H +#define NET_CHATSERVER_INTERNAL_H + +namespace Net +{ + class Connection; + + namespace ChatServer + { + extern Connection *connection; + } +} + +#endif diff --git a/src/net/manaserv/chatserver/party.cpp b/src/net/manaserv/chatserver/party.cpp new file mode 100644 index 00000000..26b45346 --- /dev/null +++ b/src/net/manaserv/chatserver/party.cpp @@ -0,0 +1,79 @@ +/* + * The Mana World + * Copyright (C) 2008 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 "party.h" + +#include "internal.h" + +#include "net/manaserv/connection.h" +#include "net/manaserv/protocol.h" + +#include "net/messageout.h" + +#include "log.h" + +void Net::ChatServer::Party::invitePlayer(const std::string &name) +{ + logger->log("Sending PCMSG_PARTY_INVITE"); + MessageOut msg(PCMSG_PARTY_INVITE); + + msg.writeString(name); + + Net::ChatServer::connection->send(msg); +} + +void Net::ChatServer::Party::acceptInvite(const std::string &name) +{ + logger->log("Sending PCMSG_PARTY_ACCEPT_INVITE"); + MessageOut msg(PCMSG_PARTY_ACCEPT_INVITE); + + msg.writeString(name); + + Net::ChatServer::connection->send(msg); +} + +void Net::ChatServer::Party::rejectInvite(const std::string &name) +{ + logger->log("Sending PCMSG_PARTY_REJECT_INVITE"); + MessageOut msg(PCMSG_PARTY_REJECT_INVITE); + + msg.writeString(name); + + Net::ChatServer::connection->send(msg); +} + +void Net::ChatServer::Party::getPartyMembers() +{ + logger->log("Sending PCMSG_PARTY_GET_MEMBERS"); +// MessageOut msg(PCMSG_GUILD_GET_MEMBERS); + +// msg.writeInt16(guildId); + +// Net::ChatServer::connection->send(msg); +} + +void Net::ChatServer::Party::quitParty() +{ + logger->log("Sending PCMSG_PARTY_QUIT"); + MessageOut msg(PCMSG_PARTY_QUIT); + + Net::ChatServer::connection->send(msg); +} diff --git a/src/net/manaserv/chatserver/party.h b/src/net/manaserv/chatserver/party.h new file mode 100644 index 00000000..3850c283 --- /dev/null +++ b/src/net/manaserv/chatserver/party.h @@ -0,0 +1,61 @@ +/* + * The Mana World + * Copyright (C) 2008 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_CHATSERVER_PARTY_H +#define NET_CHATSERVER_PARTY_H + +#include <iosfwd> + +namespace Net +{ + namespace ChatServer + { + namespace Party + { + /** + * Invite a player to the party. + */ + void invitePlayer(const std::string &name); + + /** + * Accept an invite another player has sent to join their party + */ + void acceptInvite(const std::string &name); + + /** + * Reject an invite from another player to join their party + */ + void rejectInvite(const std::string &name); + + /** + * Get a list of party members + */ + void getPartyMembers(); + + /** + * Leave party + */ + void quitParty(); + } + } +} + +#endif |