Exemplo n.º 1
0
        /// <summary>
        /// Constructs a new SquelchDB for network sending
        /// </summary>
        public SquelchDB(List <CharacterPropertiesSquelch> squelches, SquelchMask globals)
        {
            Accounts   = new Dictionary <string, uint>();
            Characters = new Dictionary <uint, SquelchInfo>();
            Globals    = new SquelchInfo();

            foreach (var squelch in squelches)
            {
                var squelchPlayer = PlayerManager.FindByGuid(squelch.SquelchCharacterId);
                if (squelchPlayer == null)
                {
                    log.Warn($"BuildSquelchDB(): couldn't find character {squelch.SquelchCharacterId:X8}");
                    continue;
                }

                if (squelch.SquelchAccountId == 0)
                {
                    // chracter squelch
                    var squelchInfo = new SquelchInfo((SquelchMask)squelch.Type, squelchPlayer.Name, false);

                    Characters.Add(squelch.SquelchCharacterId, squelchInfo);
                }
                else
                {
                    // account squelch
                    Accounts.Add(squelchPlayer.Account.AccountName, squelchPlayer.Guid.Full);
                }
            }

            // global squelch
            if (globals != SquelchMask.None)
            {
                Globals.Filters.Add(globals);
            }
        }
Exemplo n.º 2
0
        public SquelchInfo(SquelchMask filter, string playerName, bool account)
        {
            // not sure why this is sent 4x..
            // if not sent 4x, then the 'checkbox' in the chat menu doesn't toggle

            // there doesn't appear to be any pcaps of players performing per-channel character squelches,
            // so not sure how those were handled for this packet.

            Filters = new List <SquelchMask>()
            {
                filter, filter, filter, filter
            };
            PlayerName = playerName;
            Account    = account;
        }
Exemplo n.º 3
0
        public static SquelchMask Add(this SquelchMask maskA, SquelchMask maskB)
        {
            if (maskA == SquelchMask.AllChannels || maskB == SquelchMask.AllChannels)
            {
                return(SquelchMask.AllChannels);
            }

            var result = maskA | maskB;

            if (result == SquelchMask.Combined)
            {
                return(SquelchMask.AllChannels);
            }
            else
            {
                return(result);
            }
        }
Exemplo n.º 4
0
        public static SquelchMask Remove(this SquelchMask maskA, SquelchMask maskB)
        {
            if (maskB == SquelchMask.AllChannels)
            {
                return(SquelchMask.None);
            }

            var result = maskA;

            if (result == SquelchMask.AllChannels)
            {
                result = SquelchMask.Combined;
            }

            result &= ~maskB;

            if (result == SquelchMask.Combined)
            {
                result = SquelchMask.AllChannels;
            }

            return(result);
        }