private static void HandleApplicationResponse(GameSession session, PacketReader packet) { long guildApplicationId = packet.ReadLong(); byte response = packet.ReadByte(); Guild guild = GameServer.GuildManager.GetGuildById(session.Player.Guild.Id); if (guild == null) { return; } GuildApplication application = guild.Applications.FirstOrDefault(x => x.Id == guildApplicationId); if (application == null) { return; } Player applier = GameServer.Storage.GetPlayerById(application.CharacterId); session.Send(GuildPacket.ApplicationResponse(guildApplicationId, applier.Name, response)); if (response == 1) { session.Send(GuildPacket.InviteNotification(applier.Name, response)); } guild.BroadcastPacketGuild(GuildPacket.ApplicationResponseBroadcastNotice(session.Player.Name, applier.Name, response, guildApplicationId)); application.Remove(applier, guild); if (applier.Session != null) { applier.Session.Send(GuildPacket.ApplicationResponseToApplier(guild.Name, guildApplicationId, response)); } if (response == 0) { if (applier.Session != null) { // TODO: Send System mail for rejection } return; } guild.AddMember(applier); if (applier.Session != null) { applier.Session.Send(GuildPacket.InviteResponseConfirm(session.Player, applier, guild, response)); applier.Session.FieldManager.BroadcastPacket(GuildPacket.UpdateGuildTag2(applier, guild.Name)); } GuildMember member = guild.Members.FirstOrDefault(x => x.Player == applier); guild.BroadcastPacketGuild(GuildPacket.MemberBroadcastJoinNotice(member, session.Player.Name, false)); guild.BroadcastPacketGuild(GuildPacket.MemberJoin(applier)); guild.BroadcastPacketGuild(GuildPacket.UpdateGuild(guild)); }
private static void HandleInviteResponse(GameSession session, PacketReader packet) { long guildId = packet.ReadLong(); string guildName = packet.ReadUnicodeString(); packet.ReadShort(); string inviterName = packet.ReadUnicodeString(); string inviteeName = packet.ReadUnicodeString(); byte response = packet.ReadByte(); // 01 accept Guild guild = GameServer.GuildManager.GetGuildById(guildId); if (guild == null) { return; } Player inviter = GameServer.PlayerManager.GetPlayerByName(inviterName); if (inviter == null) { return; } if (response == 00) { inviter.Session.Send(GuildPacket.InviteNotification(inviteeName, 256)); session.Send(GuildPacket.InviteResponseConfirm(inviter, session.Player, guild, response)); return; } guild.AddMember(session.Player); GuildMember member = guild.Members.FirstOrDefault(x => x.Player == session.Player); if (member == null) { return; } inviter.Session.Send(GuildPacket.InviteNotification(inviteeName, response)); session.Send(GuildPacket.InviteResponseConfirm(inviter, session.Player, guild, response)); session.FieldManager.BroadcastPacket(GuildPacket.UpdateGuildTag2(session.Player, guildName)); guild.BroadcastPacketGuild(GuildPacket.MemberBroadcastJoinNotice(member, inviterName, true)); guild.BroadcastPacketGuild(GuildPacket.MemberJoin(session.Player), session); session.Send(GuildPacket.UpdateGuild(guild)); TrophyManager.OnGuildJoin(session.Player); }