summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorErik Schilling <ablu.erikschilling@googlemail.com>2012-04-16 22:17:20 +0200
committerErik Schilling <ablu.erikschilling@googlemail.com>2012-04-19 19:11:59 +0200
commite9eda63dcad0b842d637c13e415ef4f751ea2adf (patch)
treee92b8580a4027cdb8893e628e93d3bcd80790675 /src/net
parent0a9bcdc30ce9db0e53da02211ec548f529245c99 (diff)
downloadmana-e9eda63dcad0b842d637c13e415ef4f751ea2adf.tar.gz
mana-e9eda63dcad0b842d637c13e415ef4f751ea2adf.tar.bz2
mana-e9eda63dcad0b842d637c13e415ef4f751ea2adf.tar.xz
mana-e9eda63dcad0b842d637c13e415ef4f751ea2adf.zip
Client side fix for manaserv guild system
- kick code untested because no kick button exists yet Reviewed-by: bjorn.
Diffstat (limited to 'src/net')
-rw-r--r--src/net/manaserv/guildhandler.cpp36
-rw-r--r--src/net/manaserv/manaserv_protocol.h6
2 files changed, 36 insertions, 6 deletions
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