summaryrefslogtreecommitdiff
path: root/src/net/manaserv
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/manaserv')
-rw-r--r--src/net/manaserv/chatserver/guild.cpp99
-rw-r--r--src/net/manaserv/chatserver/guild.h67
-rw-r--r--src/net/manaserv/guildhandler.cpp88
-rw-r--r--src/net/manaserv/guildhandler.h31
4 files changed, 114 insertions, 171 deletions
diff --git a/src/net/manaserv/chatserver/guild.cpp b/src/net/manaserv/chatserver/guild.cpp
deleted file mode 100644
index 1f0990b1..00000000
--- a/src/net/manaserv/chatserver/guild.cpp
+++ /dev/null
@@ -1,99 +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 "guild.h"
-
-#include "net/manaserv/connection.h"
-#include "net/manaserv/messageout.h"
-#include "net/manaserv/protocol.h"
-
-#include "log.h"
-
-namespace ManaServ
-{
-
-extern Connection *chatServerConnection;
-
-void ChatServer::Guild::createGuild(const std::string &name)
-{
- logger->log("Sending PCMSG_GUILD_CREATE");
- MessageOut msg(PCMSG_GUILD_CREATE);
-
- msg.writeString(name);
-
- chatServerConnection->send(msg);
-}
-
-void 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);
-
- chatServerConnection->send(msg);
-}
-
-void ChatServer::Guild::acceptInvite(const std::string &name)
-{
- logger->log("Sending PCMSG_GUILD_ACCEPT");
- MessageOut msg(PCMSG_GUILD_ACCEPT);
-
- msg.writeString(name);
-
- chatServerConnection->send(msg);
-}
-
-void ChatServer::Guild::getGuildMembers(short guildId)
-{
- logger->log("Sending PCMSG_GUILD_GET_MEMBERS");
- MessageOut msg(PCMSG_GUILD_GET_MEMBERS);
-
- msg.writeInt16(guildId);
-
- chatServerConnection->send(msg);
-}
-
-void 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);
-
- chatServerConnection->send(msg);
-}
-
-void ChatServer::Guild::quitGuild(short guildId)
-{
- logger->log("Sending PCMSG_GUILD_QUIT");
- MessageOut msg(PCMSG_GUILD_QUIT);
-
- msg.writeInt16(guildId);
-
- chatServerConnection->send(msg);
-}
-
-}
diff --git a/src/net/manaserv/chatserver/guild.h b/src/net/manaserv/chatserver/guild.h
deleted file mode 100644
index 7b9aef04..00000000
--- a/src/net/manaserv/chatserver/guild.h
+++ /dev/null
@@ -1,67 +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_MANASERV_CHATSERVER_GUILD_H
-#define NET_MANASERV_CHATSERVER_GUILD_H
-
-#include <iosfwd>
-
-namespace ManaServ
-{
- 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 // NET_MANASERV_CHATSERVER_GUILD_H
diff --git a/src/net/manaserv/guildhandler.cpp b/src/net/manaserv/guildhandler.cpp
index d4bf2397..e71f4d20 100644
--- a/src/net/manaserv/guildhandler.cpp
+++ b/src/net/manaserv/guildhandler.cpp
@@ -23,7 +23,9 @@
#include "net/messagein.h"
-#include "net/manaserv/chatserver/guild.h"
+#include "net/manaserv/connection.h"
+#include "net/manaserv/messagein.h"
+#include "net/manaserv/messageout.h"
#include "net/manaserv/protocol.h"
#include "gui/widgets/channeltab.h"
@@ -41,8 +43,12 @@
#include <iostream>
+Net::GuildHandler *guildHandler;
+
namespace ManaServ {
+extern Connection *chatServerConnection;
+
GuildHandler::GuildHandler()
{
static const Uint16 _messages[] = {
@@ -58,6 +64,7 @@ GuildHandler::GuildHandler()
};
handledMessages = _messages;
+ guildHandler = this;
}
void GuildHandler::handleMessage(Net::MessageIn &msg)
@@ -178,9 +185,10 @@ void GuildHandler::handleMessage(Net::MessageIn &msg)
logger->log("Received CPMSG_GUILD_INVITED");
std::string inviterName = msg.readString();
std::string guildName = msg.readString();
+ int guildId = msg.readInt16();
// Open a dialog asking if the player accepts joining the guild.
- guildWindow->openAcceptDialog(inviterName, guildName);
+ guildWindow->openAcceptDialog(inviterName, guildName, guildId);
} break;
case CPMSG_GUILD_PROMOTE_MEMBER_RESPONSE:
@@ -250,4 +258,80 @@ void GuildHandler::joinedGuild(Net::MessageIn &msg)
BY_CHANNEL);
}
+void GuildHandler::create(const std::string &name)
+{
+ MessageOut msg(PCMSG_GUILD_CREATE);
+ msg.writeString(name);
+ chatServerConnection->send(msg);
+}
+
+void GuildHandler::invite(int guildId, const std::string &name)
+{
+ MessageOut msg(PCMSG_GUILD_INVITE);
+ msg.writeInt16(guildId);
+ msg.writeString(name);
+ chatServerConnection->send(msg);
+}
+
+void GuildHandler::invite(int guildId, Player *player)
+{
+ invite(guildId, player->getName());
+}
+
+void GuildHandler::inviteResponse(int guildId, bool response)
+{
+ /*MessageOut msg(PCMSG_GUILD_ACCEPT);
+ msg.writeString(name);
+ chatServerConnection->send(msg);*/
+}
+
+void GuildHandler::leave(int guildId)
+{
+ MessageOut msg(PCMSG_GUILD_QUIT);
+ msg.writeInt16(guildId);
+ chatServerConnection->send(msg);
+}
+
+void GuildHandler::kick(int guildId, int playerId)
+{
+ // TODO
+}
+
+void GuildHandler::chat(int guildId, const std::string &text)
+{
+ // TODO
+}
+
+void GuildHandler::memberList(int guildId)
+{
+ MessageOut msg(PCMSG_GUILD_GET_MEMBERS);
+ msg.writeInt16(guildId);
+ chatServerConnection->send(msg);
+}
+
+void GuildHandler::changeMemberPostion(int guildId, int playerId, int level)
+{
+ /*MessageOut msg(PCMSG_GUILD_PROMOTE_MEMBER);
+ msg.writeInt16(guildId);
+ msg.writeString(name);
+ msg.writeInt8(level);
+ chatServerConnection->send(msg);*/
+}
+
+void GuildHandler::requestAlliance(int guildId, int otherGuildId)
+{
+ // TODO
+}
+
+void GuildHandler::requestAllianceResponse(int guildId, int otherGuildId,
+ bool response)
+{
+ // TODO
+}
+
+void GuildHandler::endAlliance(int guildId, int otherGuildId)
+{
+ // TODO
+}
+
} // namespace ManaServ
diff --git a/src/net/manaserv/guildhandler.h b/src/net/manaserv/guildhandler.h
index edf5eb8f..d80f0b33 100644
--- a/src/net/manaserv/guildhandler.h
+++ b/src/net/manaserv/guildhandler.h
@@ -22,19 +22,44 @@
#ifndef NET_MANASERV_GUILDHANDLER_H
#define NET_MANASERV_GUILDHANDLER_H
-#include "net/manaserv/messagehandler.h"
+#include "net/guildhandler.h"
-#include <string>
+#include "net/manaserv/messagehandler.h"
namespace ManaServ {
-class GuildHandler : public MessageHandler
+class GuildHandler : public Net::GuildHandler, public MessageHandler
{
public:
GuildHandler();
void handleMessage(Net::MessageIn &msg);
+ void create(const std::string &name);
+
+ void invite(int guildId, const std::string &name);
+
+ void invite(int guidId, Player *player);
+
+ void inviteResponse(int guidId, bool response);
+
+ void leave(int guildId);
+
+ void kick(int guildId, int playerId);
+
+ void chat(int guildId, const std::string &text);
+
+ void memberList(int guildId);
+
+ void changeMemberPostion(int guildId, int playerId, int level);
+
+ void requestAlliance(int guildId, int otherGuildId);
+
+ void requestAllianceResponse(int guildId, int otherGuildId,
+ bool response);
+
+ void endAlliance(int guildId, int otherGuildId);
+
protected:
void joinedGuild(Net::MessageIn &msg);
};