From 15014d358424bf5f74a2d9b7afd08692b591a448 Mon Sep 17 00:00:00 2001 From: David Athay Date: Thu, 6 Mar 2008 15:07:47 +0000 Subject: Fixed rejoining guilds after closing client --- src/net/guildhandler.cpp | 27 ++++++++++++++++----------- src/net/guildhandler.h | 8 ++++---- 2 files changed, 20 insertions(+), 15 deletions(-) (limited to 'src/net') diff --git a/src/net/guildhandler.cpp b/src/net/guildhandler.cpp index 5bacaaa1..88528584 100644 --- a/src/net/guildhandler.cpp +++ b/src/net/guildhandler.cpp @@ -37,6 +37,7 @@ #include "chatserver/guild.h" #include "../gui/guildwindow.h" +#include "../gui/chat.h" #include "../guild.h" #include "../log.h" #include "../localplayer.h" @@ -67,10 +68,8 @@ void GuildHandler::handleMessage(MessageIn &msg) logger->log("Received CPMSG_GUILD_CREATE_RESPONSE"); if(msg.readInt8() == ERRMSG_OK) { - short guildId = msg.readInt16(); - std::string guildName = msg.readString(); // TODO - Acknowledge guild was created - joinedGuild(guildId, guildName, true); + joinedGuild(msg); } } break; @@ -89,9 +88,7 @@ void GuildHandler::handleMessage(MessageIn &msg) if(msg.readInt8() == ERRMSG_OK) { // TODO - Acknowledge accepted into guild - short guildId = msg.readInt16(); - std::string guildName = msg.readString(); - joinedGuild(guildId, guildName, false); + joinedGuild(msg); } } break; @@ -131,20 +128,28 @@ void GuildHandler::handleMessage(MessageIn &msg) case CPMSG_GUILD_REJOIN: { logger->log("Received CPMSG_GUILD_REJOIN"); - std::string guildName = msg.readString(); - short guildId = msg.readInt16(); - bool leader = msg.readInt8(); - joinedGuild(guildId, guildName, leader); + joinedGuild(msg); } break; } } -void GuildHandler::joinedGuild(short guildId, const std::string &guildName, bool leader) +void GuildHandler::joinedGuild(MessageIn &msg) { + std::string guildName = msg.readString(); + short guildId = msg.readInt16(); + bool leader = msg.readInt8(); + short channelId = msg.readInt16(); + // Add guild to player and create new guild tab Guild *guild = player_node->addGuild(guildId, leader); guild->setName(guildName); guildWindow->newGuildTab(guildName); guildWindow->requestMemberList(guildId); + + // Automatically create the guild channel + // COMMENT: Should this go here?? + chatWindow->addChannel(channelId, guildName); + chatWindow->createNewChannelTab(guildName); + chatWindow->chatLog("Guild Channel", BY_SERVER, guildName); } diff --git a/src/net/guildhandler.h b/src/net/guildhandler.h index c76682b2..5ac0a52e 100644 --- a/src/net/guildhandler.h +++ b/src/net/guildhandler.h @@ -3,7 +3,7 @@ * A file part of The Mana World * * Created by David Athay on 01/03/2007. - * + * * Copyright (c) 2007, The Mana World Development Team * All rights reserved. * @@ -39,11 +39,11 @@ class GuildHandler : public MessageHandler { public: GuildHandler(); - + void handleMessage(MessageIn &msg); - + protected: - void joinedGuild(short guildId, const std::string &guildName, bool leader); + void joinedGuild(MessageIn &msg); }; #endif -- cgit v1.2.3-70-g09d2