Пример #1
0
        /// <summary>
        /// Checks if packet is displayed in packet list.
        /// </summary>
        /// <param name="packet">Packet to check.</param>
        /// <returns>True if visible, false otherwise.</returns>
        public bool IsDisplayed(UltimaPacket packet)
        {
            UltimaPacketFilterTable  table      = Table;
            UltimaPacketFilterTable  childTable = null;
            IUltimaPacketFilterEntry item       = null;
            int i = 0;

            do
            {
                item       = table[packet.Data[i++]];
                childTable = item as UltimaPacketFilterTable;

                if (childTable != null)
                {
                    if (!childTable.IsChecked)
                    {
                        return(false);
                    }

                    table = childTable;
                }
            }while (childTable != null);

            UltimaPacketFilterEntry entry = item as UltimaPacketFilterEntry;

            if (entry != null)
            {
                return(entry.IsVisible && entry.IsChecked && entry.IsDisplayed(packet));
            }

            return(false);
        }
Пример #2
0
        /// <summary>
        /// Checks if packet is displayed in packet list.
        /// </summary>
        /// <param name="packet">Packet to check.</param>
        /// <returns>True if visible, false otherwise.</returns>
        public bool IsDisplayed(UltimaPacket packet)
        {
            UltimaPacketFilterTable  table      = Table;
            UltimaPacketFilterTable  childTable = null;
            IUltimaPacketFilterEntry item       = null;
            int i = 0;


            //the filter is now correctly filtering the subcommands but this is the best way to find cmd.subcmd[.subsubcmd]
            string[] sids = packet.Ids.Split('.');
            byte[]   ids  = new byte[sids.Length];
            foreach (string s in sids)
            {
                ids[i++] = Convert.ToByte(s.Substring(0, 2), 16);
            }

            i = 0;
            do
            {
                item       = table[ids[i++]];
                childTable = item as UltimaPacketFilterTable;

                if (childTable != null)
                {
                    if (childTable.IsChecked)
                    {
                        return(true);
                    }

                    table = childTable;
                }
            }while (childTable != null && i < ids.Length);

            UltimaPacketFilterEntry entry = item as UltimaPacketFilterEntry;

            if (entry != null)
            {
                return(entry.IsVisible && entry.IsChecked && entry.IsDisplayed(packet));
            }

            return(false);
        }