public ICharacterSet GetCharacterSet(Character chr, bool asGroup) { // we are working with a non-synchronized Character object here if (asGroup) { var group = chr.Group; if (group == null || !group.IsLeader(chr)) { // invalid request GroupHandler.SendResult(chr, GroupResultType.Swap, GroupResult.DontHavePermission); } else { var chrs = group.GetAllCharacters(); // if no characters in the group, return the original character if (chrs.Length == 0) { return(chr); } // make sure the group isn't bigger than the max team size for this BG if (chrs.Length > _parentQueue.Template.MaxPlayersPerTeam) { BattlegroundHandler.SendBattlegroundError(chr, BattlegroundJoinError.GroupJoinedNotEligible); return(null); } // make sure there are no deserters foreach (Character groupChr in chrs) { if (groupChr != null && groupChr.Battlegrounds.IsDeserter) { BattlegroundHandler.SendBattlegroundError(group, BattlegroundJoinError.Deserter); return(null); } } var list = new SynchronizedCharacterList(Side.GetFactionGroup()); foreach (var groupChr in chrs) { if (groupChr.IsInWorld && (groupChr.GodMode || _parentQueue.CanEnter(groupChr))) { list.Add(groupChr); } else { // cannot join the same team BattlegroundHandler.SendBattlegroundError(groupChr, BattlegroundJoinError.GroupJoinedNotEligible); } } return(list); } } else { // enqueue the character if they aren't a deserter if (!chr.Battlegrounds.IsDeserter) { return(chr); } BattlegroundHandler.SendBattlegroundError(chr, BattlegroundJoinError.Deserter); } return(null); }