summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gui/socialwindow.cpp5
-rw-r--r--src/net/manaserv/guildhandler.cpp36
-rw-r--r--src/net/manaserv/manaserv_protocol.h6
3 files changed, 39 insertions, 8 deletions
diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp
index 421d639d..4203a137 100644
--- a/src/gui/socialwindow.cpp
+++ b/src/gui/socialwindow.cpp
@@ -123,9 +123,10 @@ public:
if (!name.empty())
{
+ Net::getGuildHandler()->invite(mGuild->getId(), name);
SERVER_NOTICE(strprintf(_("Invited user %s to guild %s."),
- name.c_str(),
- mGuild->getName().c_str()))
+ name.c_str(),
+ mGuild->getName().c_str()))
}
mInviteDialog = NULL;
}
diff --git a/src/net/manaserv/guildhandler.cpp b/src/net/manaserv/guildhandler.cpp
index a8e662ec..1378d205 100644
--- a/src/net/manaserv/guildhandler.cpp
+++ b/src/net/manaserv/guildhandler.cpp
@@ -62,6 +62,7 @@ GuildHandler::GuildHandler()
CPMSG_GUILD_INVITED,
CPMSG_GUILD_REJOIN,
CPMSG_GUILD_QUIT_RESPONSE,
+ CPMSG_GUILD_KICK_NOTIFICATION,
0
};
handledMessages = _messages;
@@ -91,11 +92,20 @@ void GuildHandler::handleMessage(Net::MessageIn &msg)
case CPMSG_GUILD_INVITE_RESPONSE:
{
logger->log("Received CPMSG_GUILD_INVITE_RESPONSE");
- if (msg.readInt8() == ERRMSG_OK)
+ const unsigned char response = msg.readInt8();
+ if (response == ERRMSG_OK)
{
// TODO - Acknowledge invite was sent
SERVER_NOTICE(_("Invite sent."))
}
+ else if (response == ERRMSG_ALREADY_MEMBER)
+ {
+ SERVER_NOTICE(_("Invited player is already in that guild."));
+ }
+ else if (response == ERRMSG_LIMIT_REACHED)
+ {
+ SERVER_NOTICE(_("Invited player can't join another guild."));
+ }
} break;
case CPMSG_GUILD_ACCEPT_RESPONSE:
@@ -235,6 +245,23 @@ void GuildHandler::handleMessage(Net::MessageIn &msg)
}
}
} break;
+ case CPMSG_GUILD_KICK_NOTIFICATION:
+ {
+ logger->log("Received CPMSG_GUILD_KICK_NOTIFICATION");
+
+ const int guildId = msg.readInt16();
+ std::string player = msg.readString();
+ Guild *guild = local_player->getGuild(guildId);
+ if (guild)
+ {
+ Channel *channel = channelManager->findByName(guild->getName());
+ channelManager->removeChannel(channel);
+ local_player->removeGuild(guildId);
+ SERVER_NOTICE(strprintf(
+ _("Player %s kicked you out of guild %s"),
+ player.c_str(), guild->getName().c_str()));
+ }
+ } break;
}
}
@@ -283,9 +310,10 @@ void GuildHandler::invite(int guildId, Being *being)
void GuildHandler::inviteResponse(int guildId, bool response)
{
- /*MessageOut msg(PCMSG_GUILD_ACCEPT);
- msg.writeString(name);
- chatServerConnection->send(msg);*/
+ MessageOut msg(PCMSG_GUILD_ACCEPT);
+ msg.writeInt16(guildId);
+ msg.writeInt8(response ? 1 : 0);
+ chatServerConnection->send(msg);
}
void GuildHandler::leave(int guildId)
diff --git a/src/net/manaserv/manaserv_protocol.h b/src/net/manaserv/manaserv_protocol.h
index 79dbc542..c8b16593 100644
--- a/src/net/manaserv/manaserv_protocol.h
+++ b/src/net/manaserv/manaserv_protocol.h
@@ -176,7 +176,7 @@ enum {
CPMSG_GUILD_CREATE_RESPONSE = 0x0351, // B error, W guild, B rights, W channel
PCMSG_GUILD_INVITE = 0x0352, // W id, S name
CPMSG_GUILD_INVITE_RESPONSE = 0x0353, // B error
- PCMSG_GUILD_ACCEPT = 0x0354, // W id
+ PCMSG_GUILD_ACCEPT = 0x0354, // W id, B accepted (0 if false, 1 if true)
CPMSG_GUILD_ACCEPT_RESPONSE = 0x0355, // B error, W guild, B rights, W channel
PCMSG_GUILD_GET_MEMBERS = 0x0356, // W id
CPMSG_GUILD_GET_MEMBERS_RESPONSE = 0x0357, // S names, B online
@@ -187,6 +187,7 @@ enum {
CPMSG_GUILD_PROMOTE_MEMBER_RESPONSE = 0x0366, // B error
PCMSG_GUILD_KICK_MEMBER = 0x0370, // W guild, S name
CPMSG_GUILD_KICK_MEMBER_RESPONSE = 0x0371, // B error
+ CPMSG_GUILD_KICK_NOTIFICATION = 0x0372, // W guild, S player that kicked
CPMSG_GUILD_INVITED = 0x0388, // S char name, S guild name, W id
CPMSG_GUILD_REJOIN = 0x0389, // S name, W guild, W rights, W channel, S announce
@@ -279,7 +280,8 @@ enum {
ERRMSG_SERVER_FULL, // the server is overloaded
ERRMSG_TIME_OUT, // data failed to arrive in due time
ERRMSG_LIMIT_REACHED, // limit reached
- ERRMSG_ADMINISTRATIVE_LOGOFF // kicked by server administrator
+ ERRMSG_ADMINISTRATIVE_LOGOFF, // kicked by server administrator
+ ERRMSG_ALREADY_MEMBER // is already member of guild/party
};
// used in AGMSG_REGISTER_RESPONSE to show state of item db