void ChatHandler::handleGuildGetMembers(ChatClient &client, MessageIn &msg) { MessageOut reply(CPMSG_GUILD_GET_MEMBERS_RESPONSE); short guildId = msg.readInt16(); Guild *guild = guildManager->findById(guildId); // check for valid guild // write a list of member names that belong to the guild if (guild) { // make sure the requestor is in the guild if (guild->checkInGuild(client.characterId)) { reply.writeInt8(ERRMSG_OK); reply.writeInt16(guildId); std::list<GuildMember*> memberList = guild->getMembers(); std::list<GuildMember*>::const_iterator itr_end = memberList.end(); for (std::list<GuildMember*>::iterator itr = memberList.begin(); itr != itr_end; ++itr) { CharacterData *c = storage->getCharacter((*itr)->mId, nullptr); std::string memberName = c->getName(); reply.writeString(memberName); reply.writeInt8(mPlayerMap.find(memberName) != mPlayerMap.end()); } } } else { reply.writeInt8(ERRMSG_FAILURE); } client.send(reply); }
void ChatHandler::sendGuildListUpdate(Guild *guild, const std::string &characterName, char eventId) { MessageOut msg(CPMSG_GUILD_UPDATE_LIST); msg.writeInt16(guild->getId()); msg.writeString(characterName); msg.writeInt8(eventId); std::map<std::string, ChatClient*>::const_iterator chr; std::list<GuildMember*> members = guild->getMembers(); for (std::list<GuildMember*>::const_iterator itr = members.begin(); itr != members.end(); ++itr) { CharacterData *c = storage->getCharacter((*itr)->mId, nullptr); chr = mPlayerMap.find(c->getName()); if (chr != mPlayerMap.end()) { chr->second->send(msg); } } }