Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            UltimaPacket packet = Packet;

            if (packet != null)
            {
                try
                {
                    if (_SaveFileDialog == null)
                    {
                        _SaveFileDialog                 = new SaveFileDialog();
                        _SaveFileDialog.Filter          = "Ultima Packet (*.packet)|*.packet";
                        _SaveFileDialog.CheckPathExists = true;
                        _SaveFileDialog.Title           = "Save Packet";
                    }

                    if (_SaveFileDialog.ShowDialog(App.Window) == true)
                    {
                        using (FileStream stream = File.Create(_SaveFileDialog.FileName, packet.Data.Length))
                        {
                            stream.Write(packet.Data, 0, packet.Data.Length);
                        }
                    }
                }
                catch (Exception ex)
                {
                    App.Window.ShowNotification(NotificationType.Error, ex);
                }
            }
        }
        private void UpdatePacket()
        {
            UltimaPacket packet = Packet;

            if (packet is GenericGumpPacket ||
                packet is WorldObjectPacket ||
                packet is MobileIncommingPacket)
            {
                Generate.Visibility = Visibility.Visible;
            }
            else
            {
                Generate.Visibility = Visibility.Collapsed;
            }

            if (packet is IUltimaEntity)
            {
                FindRelatives.Visibility = Visibility.Visible;
            }
            else
            {
                FindRelatives.Visibility = Visibility.Collapsed;
            }

            if (packet != null)
            {
                CopyToClipboard.Visibility = Visibility.Visible;
                OpenInNewWindow.Visibility = Visibility.Visible;
            }
            else
            {
                CopyToClipboard.Visibility = Visibility.Collapsed;
                OpenInNewWindow.Visibility = Visibility.Collapsed;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Constructs a new instance of Globals.
        /// </summary>
        public Globals()
        {
            // Register packets
            UltimaPacket.RegisterPackets();

            // Generators
            _ItemDefinitions = new UltimaItemDefinitions();
            _ItemProperties  = new UltimaItemProperties();

            // Get enhanced client folder
            _LegacyClientFolder = SpyHelper.ClassicClientFolder;

            if (_LegacyClientFolder != null)
            {
                string clilocFilePath = Path.Combine(_LegacyClientFolder, "Cliloc.enu");

                if (File.Exists(clilocFilePath))
                {
                    _Clilocs = UltimaStringCollection.FromFile(clilocFilePath);
                }

                InitializeLegacyAssets(_LegacyClientFolder);
            }

            _EnhancedClientFolder = SpyHelper.EnhancedClientFolder;

            if (_EnhancedClientFolder != null)
            {
                string clilocPackage = Path.Combine(_EnhancedClientFolder, "string_collection.uop");

                if (File.Exists(clilocPackage))
                {
                    _Clilocs = UltimaStringCollection.FromPackage(clilocPackage);
                }

                if (_LegacyAssets == null)
                {
                    InitializeEnhancedAssets(_EnhancedClientFolder);
                }
            }

            // Initialize VLC player
            _VlcInstallationFolder = VlcPlayer.DefaultInstallationFolder;

            if (!String.IsNullOrEmpty(_VlcInstallationFolder))
            {
                try
                {
                    VlcPlayer.Initialize(_VlcInstallationFolder);

                    _VlcPlayer = new VlcPlayer();
                }
                catch
                {
                    _VlcInstallationFolder = null;
                }
            }
        }
Ejemplo n.º 5
0
        private void PacketsView_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            UltimaPacket packet = PacketsView.SelectedValue as UltimaPacket;

            if (packet != null)
            {
                PropertiesWindow properties = new PropertiesWindow();
                properties.Properties.Packet = packet;
                properties.Show();
            }
        }
Ejemplo n.º 6
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            UltimaPacket packet = value as UltimaPacket;

            if (packet != null)
            {
                return(new UltimaPacketValue(packet));
            }

            return(null);
        }
Ejemplo n.º 7
0
        private void UpdatePacket()
        {
            UltimaPacket packet = Packet;

            if (packet == null)
            {
                Save.Visibility = Visibility.Collapsed;
                Open.Visibility = Visibility.Collapsed;
                Text.Text       = String.Empty;
                return;
            }
            else
            {
                Save.Visibility = Visibility.Visible;
                Open.Visibility = Visibility.Visible;
            }

            byte[]        data = packet.Data;
            StringBuilder binaryBuilder = new StringBuilder(data.Length * 3 + data.Length / 8);
            StringBuilder textBuilder = new StringBuilder(data.Length);
            byte          b1, b2;

            for (int i = 0; i < data.Length; i++)
            {
                b1 = (byte)(data[i] >> 4);
                b2 = (byte)(data[i] & 0xF);

                binaryBuilder.Append((char)(b1 > 9 ? b1 + 0x37 : b1 + 0x30));
                binaryBuilder.Append((char)(b2 > 9 ? b2 + 0x37 : b2 + 0x30));
                binaryBuilder.Append(' ');

                b1 = data[i];

                // Crap
                if (b1 < 0x20 || b1 == 0xB7 || b1 == 0xFF)
                {
                    b1 = (byte)'.';
                }

                textBuilder.Append((char)b1);

                if ((i + 1) % 8 == 0)
                {
                    binaryBuilder.Remove(binaryBuilder.Length - 1, 1);
                    binaryBuilder.AppendLine();
                    textBuilder.AppendLine();
                }
            }

            Binary.Text = binaryBuilder.ToString();
            Text.Text   = textBuilder.ToString();
        }
Ejemplo n.º 8
0
 public ContainerItem(UltimaPacket parent, BigEndianReader reader)
 {
     _Parent       = parent;
     _Serial       = reader.ReadUInt32();
     _ItemID       = reader.ReadInt16();
     _ItemIDOffset = reader.ReadByte();
     _Amount       = reader.ReadInt16();
     _X            = reader.ReadInt16();
     _Y            = reader.ReadInt16();
     _GridLocation = reader.ReadByte();
     _ParentSerial = reader.ReadUInt32();
     _Hue          = reader.ReadInt16();
 }
Ejemplo n.º 9
0
 public ContainerItem( UltimaPacket parent, BigEndianReader reader )
 {
     _Parent = parent;
     _Serial = reader.ReadUInt32();
     _ItemID = reader.ReadInt16();
     _ItemIDOffset = reader.ReadByte();
     _Amount = reader.ReadInt16();
     _X = reader.ReadInt16();
     _Y = reader.ReadInt16();
     _GridLocation = reader.ReadByte();
     _ParentSerial = reader.ReadUInt32();
     _Hue = reader.ReadInt16();
 }
Ejemplo n.º 10
0
 public CitiesInfo(UltimaPacket parent, BigEndianReader reader)
 {
     _Parent       = parent;
     _CitieIndex   = reader.ReadByte();
     _CitieName    = reader.ReadAsciiString(32);
     _BuildingName = reader.ReadAsciiString(32);
     _X            = reader.ReadUInt32();
     _Y            = reader.ReadUInt32();
     _Z            = reader.ReadUInt32();
     _Map          = reader.ReadUInt32();
     _Cliloc       = reader.ReadUInt32();
     uint unk = reader.ReadUInt32();
 }
Ejemplo n.º 11
0
        private void SpyHelper_OnPacket(UltimaPacket relative)
        {
            if (Packet == null)
            {
                return;
            }

            IUltimaEntity packet = Packet as IUltimaEntity;
            IUltimaEntity entity = relative as IUltimaEntity;

            if (packet != null && entity != null && packet.Serial == entity.Serial)
            {
                Relatives.Add(relative);
            }
        }
Ejemplo n.º 12
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            UltimaPacketValue packetValue = value as UltimaPacketValue;

            if (packetValue != null)
            {
                UltimaPacket packet = packetValue.Object as UltimaPacket;

                if (packet != null)
                {
                    return(String.Format("{0} - {1}", packet.Ids, packet.Name));
                }
            }

            return("Packet Properties");
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Adds packet to list.
        /// </summary>
        /// <param name="packet">Packet to add.</param>
        public void AddPacket(UltimaPacket packet)
        {
            try
            {
                Count++;
                Packets.Add(packet);

                if (OnPacket != null)
                {
                    OnPacket(packet);
                }
            }
            catch (Exception ex)
            {
                App.Window.ShowNotification(NotificationType.Error, ex);
            }
        }
Ejemplo n.º 14
0
        private void Spy_OnPacketSafe(byte[] data, bool fromClient, DateTime time)
        {
            UltimaPacket packet = null;

            try
            {
                packet = UltimaPacket.ConstructPacket(data, fromClient, time);
            }
            catch (Exception ex)
            {
                App.Window.ShowNotification(NotificationType.Error, ex);
            }

            if (packet != null)
            {
                AddPacket(packet);
            }
        }
Ejemplo n.º 15
0
        private void Open_Click(object sender, RoutedEventArgs e)
        {
            UltimaPacket packet = Packet;

            if (packet != null)
            {
                try
                {
                    BinaryWindow window = new BinaryWindow();
                    window.Binary.Packet = packet;
                    window.Show();
                }
                catch (Exception ex)
                {
                    App.Window.ShowNotification(NotificationType.Error, ex);
                }
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Determines whether packet is displayed.
        /// </summary>
        /// <param name="packet">Packet to check.</param>
        /// <returns>True if displayed, false if not.</returns>
        public bool IsDisplayed(UltimaPacket packet)
        {
            List <UltimaPacketFilterProperty> properties = Properties;

            if (properties == null)
            {
                return(true);
            }

            foreach (UltimaPacketFilterProperty property in properties)
            {
                if (property.IsChecked && !property.IsDisplayed(packet))
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 17
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);
        }
Ejemplo n.º 18
0
        private void OpenInNewWindow_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            try
            {
                UltimaPacket packet = e.Parameter as UltimaPacket;

                if (packet == null)
                {
                    return;
                }

                PropertiesWindow properties = new PropertiesWindow();
                properties.Properties.Packet = packet;
                properties.Show();
            }
            catch (Exception ex)
            {
                App.Window.ShowNotification(NotificationType.Error, ex);
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Reads packets from binary file.
        /// </summary>
        /// <param name="filePath">File to read from.</param>
        public void LoadBinary(string filePath)
        {
            List <UltimaPacket> packets = new List <UltimaPacket>();

            using (FileStream stream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                using (BinaryReader reader = new BinaryReader(stream))
                {
                    int version = reader.ReadInt32();

                    if (version > 0)
                    {
                        throw new SpyException("Unsupported file version");
                    }

                    int count = reader.ReadInt32();

                    for (int i = 0; i < count; i++)
                    {
                        try
                        {
                            UltimaPacket packet = UltimaPacket.ConstructPacket(reader);

                            if (packet != null)
                            {
                                packets.Add(packet);
                            }
                        }
                        catch (Exception ex)
                        {
                            App.Window.ShowNotification(NotificationType.Error, ex);
                        }
                    }
                }
            }

            App.Current.Dispatcher.BeginInvoke(new Action <List <UltimaPacket> >(LoadBinary_Completed), packets);
        }
Ejemplo n.º 20
0
        private bool Filter_Displayed(object o)
        {
            UltimaPacket packet = o as UltimaPacket;

            if (packet != null)
            {
                if (_Filter == null || !_Filter.Active)
                {
                    return(true);
                }

                try
                {
                    return(_Filter.IsDisplayed(packet));
                }
                catch (Exception ex)
                {
                    ShowNotification(NotificationType.Error, ex);
                }
            }

            return(true);
        }
Ejemplo n.º 21
0
 public QueryPropertiesItem( UltimaPacket parent, uint serial )
 {
     _Parent = parent;
     _Serial = serial;
 }
Ejemplo n.º 22
0
        /// <summary>
        /// Adds packet to list.
        /// </summary>
        /// <param name="packet">Packet to add.</param>
        public void AddPacket( UltimaPacket packet )
        {
            try
            {
                Count++;
                _Packets.Add( packet );

                if ( OnPacket != null )
                    OnPacket( packet );
            }
            catch ( Exception ex )
            {
                App.Window.ShowNotification( NotificationType.Error, ex );
            }
        }
Ejemplo n.º 23
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;
        }
Ejemplo n.º 24
0
 public void RemovePacket(UltimaPacket packet)
 {
     Count--;
     Packets.Remove(packet);
 }
Ejemplo n.º 25
0
        private void SpyHelper_OnPacket( UltimaPacket relative )
        {
            if ( Packet == null )
                return;

            IUltimaEntity packet = Packet as IUltimaEntity;
            IUltimaEntity entity = relative as IUltimaEntity;

            if ( packet != null && entity != null && packet.Serial == entity.Serial )
                Relatives.Add( relative );
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Determines whether packet is displayed.
        /// </summary>
        /// <param name="packet">Packet to check.</param>
        /// <returns>True if displayed, false otherwise.</returns>
        public bool IsDisplayed( UltimaPacket packet )
        {
            object value = Definition.Getter( packet );

            switch ( _Code )
            {
                case TypeCode.Boolean:
                {
                    Boolean actualValue = (Boolean) value;

                    if ( Operation == UltimaPacketFilterTypeOperation.In )
                    {
                        List<Boolean> list = (List<Boolean>) _Value;

                        foreach ( Boolean v in list )
                            if ( actualValue == v )
                                return true;
                    }

                    return false;
                }
                case TypeCode.Byte:
                {
                    Byte actualValue = (Byte) value;

                    if ( Operation == UltimaPacketFilterTypeOperation.Greater )
                    {
                        Byte compareWith = (Byte) _Value;

                        if ( actualValue > compareWith )
                            return true;
                    }
                    else if ( Operation == UltimaPacketFilterTypeOperation.Lesser )
                    {
                        Byte compareWith = (Byte) _Value;

                        if ( actualValue < compareWith )
                            return true;
                    }
                    else if ( Operation == UltimaPacketFilterTypeOperation.In )
                    {
                        List<Byte> list = (List<Byte>) _Value;

                        foreach ( Byte v in list )
                            if ( actualValue == v )
                                return true;
                    }

                    return false;
                }
                case TypeCode.Char:
                {
                    Char actualValue = (Char) value;

                    if ( Operation == UltimaPacketFilterTypeOperation.Greater )
                    {
                        Char compareWith = (Char) _Value;

                        if ( actualValue > compareWith )
                            return true;
                    }
                    else if ( Operation == UltimaPacketFilterTypeOperation.Lesser )
                    {
                        Char compareWith = (Char) _Value;

                        if ( actualValue < compareWith )
                            return true;
                    }
                    else if ( Operation == UltimaPacketFilterTypeOperation.In )
                    {
                        List<Char> list = (List<Char>) _Value;

                        foreach ( Char v in list )
                            if ( actualValue == v )
                                return true;
                    }

                    return false;
                }
                case TypeCode.Decimal:
                {
                    Decimal actualValue = (Decimal) value;

                    if ( Operation == UltimaPacketFilterTypeOperation.Greater )
                    {
                        Decimal compareWith = (Decimal) _Value;

                        if ( actualValue > compareWith )
                            return true;
                    }
                    else if ( Operation == UltimaPacketFilterTypeOperation.Lesser )
                    {
                        Decimal compareWith = (Decimal) _Value;

                        if ( actualValue < compareWith )
                            return true;
                    }
                    else if ( Operation == UltimaPacketFilterTypeOperation.In )
                    {
                        List<Decimal> list = (List<Decimal>) _Value;

                        foreach ( Decimal v in list )
                            if ( actualValue == v )
                                return true;
                    }

                    return false;
                }
                case TypeCode.Double:
                {
                    Double actualValue = (Double) value;

                    if ( Operation == UltimaPacketFilterTypeOperation.Greater )
                    {
                        Double compareWith = (Double) _Value;

                        if ( actualValue > compareWith )
                            return true;
                    }
                    else if ( Operation == UltimaPacketFilterTypeOperation.Lesser )
                    {
                        Double compareWith = (Double) _Value;

                        if ( actualValue < compareWith )
                            return true;
                    }
                    else if ( Operation == UltimaPacketFilterTypeOperation.In )
                    {
                        List<Double> list = (List<Double>) _Value;

                        foreach ( Double v in list )
                            if ( actualValue == v )
                                return true;
                    }

                    return false;
                }
                case TypeCode.Int16:
                {
                    Int16 actualValue = (Int16) value;

                    if ( Operation == UltimaPacketFilterTypeOperation.Greater )
                    {
                        Int16 compareWith = (Int16) _Value;

                        if ( actualValue > compareWith )
                            return true;
                    }
                    else if ( Operation == UltimaPacketFilterTypeOperation.Lesser )
                    {
                        Int16 compareWith = (Int16) _Value;

                        if ( actualValue < compareWith )
                            return true;
                    }
                    else if ( Operation == UltimaPacketFilterTypeOperation.In )
                    {
                        List<Int16> list = (List<Int16>) _Value;

                        foreach ( Int16 v in list )
                            if ( actualValue == v )
                                return true;
                    }

                    return false;
                }
                case TypeCode.Int32:
                {
                    Int32 actualValue = (Int32) value;

                    if ( Operation == UltimaPacketFilterTypeOperation.Greater )
                    {
                        Int32 compareWith = (Int32) _Value;

                        if ( actualValue > compareWith )
                            return true;
                    }
                    else if ( Operation == UltimaPacketFilterTypeOperation.Lesser )
                    {
                        Int32 compareWith = (Int32) _Value;

                        if ( actualValue < compareWith )
                            return true;
                    }
                    else if ( Operation == UltimaPacketFilterTypeOperation.In )
                    {
                        List<Int32> list = (List<Int32>) _Value;

                        foreach ( Int32 v in list )
                            if ( actualValue == v )
                                return true;
                    }

                    return false;
                }
                case TypeCode.Int64:
                {
                    Int64 actualValue = (Int64) value;

                    if ( Operation == UltimaPacketFilterTypeOperation.Greater )
                    {
                        Int64 compareWith = (Int64) _Value;

                        if ( actualValue > compareWith )
                            return true;
                    }
                    else if ( Operation == UltimaPacketFilterTypeOperation.Lesser )
                    {
                        Int64 compareWith = (Int64) _Value;

                        if ( actualValue < compareWith )
                            return true;
                    }
                    else if ( Operation == UltimaPacketFilterTypeOperation.In )
                    {
                        List<Int64> list = (List<Int64>) _Value;

                        foreach ( Int64 v in list )
                            if ( actualValue == v )
                                return true;
                    }

                    return false;
                }
                case TypeCode.SByte:
                {
                    SByte actualValue = (SByte) value;

                    if ( Operation == UltimaPacketFilterTypeOperation.Greater )
                    {
                        SByte compareWith = (SByte) _Value;

                        if ( actualValue > compareWith )
                            return true;
                    }
                    else if ( Operation == UltimaPacketFilterTypeOperation.Lesser )
                    {
                        SByte compareWith = (SByte) _Value;

                        if ( actualValue < compareWith )
                            return true;
                    }
                    else if ( Operation == UltimaPacketFilterTypeOperation.In )
                    {
                        List<SByte> list = (List<SByte>) _Value;

                        foreach ( SByte v in list )
                            if ( actualValue == v )
                                return true;
                    }

                    return false;
                }
                case TypeCode.Single:
                {
                    Single actualValue = (Single) value;

                    if ( Operation == UltimaPacketFilterTypeOperation.Greater )
                    {
                        Single compareWith = (Single) _Value;

                        if ( actualValue > compareWith )
                            return true;
                    }
                    else if ( Operation == UltimaPacketFilterTypeOperation.Lesser )
                    {
                        Single compareWith = (Single) _Value;

                        if ( actualValue < compareWith )
                            return true;
                    }
                    else if ( Operation == UltimaPacketFilterTypeOperation.In )
                    {
                        List<Single> list = (List<Single>) _Value;

                        foreach ( Single v in list )
                            if ( actualValue == v )
                                return true;
                    }

                    return false;
                }
                case TypeCode.String:
                {
                    String actualValue = ( (String) value ).ToLower();

                    if ( Operation == UltimaPacketFilterTypeOperation.Contains )
                    {
                        List<String> list = (List<String>) _Value;

                        foreach ( String v in list )
                            if ( actualValue.Contains( v ) )
                                return true;
                    }
                    else if ( Operation == UltimaPacketFilterTypeOperation.In )
                    {
                        List<String> list = (List<String>) _Value;

                        foreach ( String v in list )
                            if ( actualValue == v )
                                return true;
                    }

                    return false;
                }
                case TypeCode.UInt16:
                {
                    UInt16 actualValue = (UInt16) value;

                    if ( Operation == UltimaPacketFilterTypeOperation.Greater )
                    {
                        UInt16 compareWith = (UInt16) _Value;

                        if ( actualValue > compareWith )
                            return true;
                    }
                    else if ( Operation == UltimaPacketFilterTypeOperation.Lesser )
                    {
                        UInt16 compareWith = (UInt16) _Value;

                        if ( actualValue < compareWith )
                            return true;
                    }
                    else if ( Operation == UltimaPacketFilterTypeOperation.In )
                    {
                        List<UInt16> list = (List<UInt16>) _Value;

                        foreach ( UInt16 v in list )
                            if ( actualValue == v )
                                return true;
                    }

                    return false;
                }
                case TypeCode.UInt32:
                {
                    UInt32 actualValue = (UInt32) value;

                    if ( Operation == UltimaPacketFilterTypeOperation.Greater )
                    {
                        UInt32 compareWith = (UInt32) _Value;

                        if ( actualValue > compareWith )
                            return true;
                    }
                    else if ( Operation == UltimaPacketFilterTypeOperation.Lesser )
                    {
                        UInt32 compareWith = (UInt32) _Value;

                        if ( actualValue < compareWith )
                            return true;
                    }
                    else if ( Operation == UltimaPacketFilterTypeOperation.In )
                    {
                        List<UInt32> list = (List<UInt32>) _Value;

                        foreach ( UInt32 v in list )
                            if ( actualValue == v )
                                return true;
                    }

                    return false;
                }
                case TypeCode.UInt64:
                {
                    UInt64 actualValue = (UInt64) value;

                    if ( Operation == UltimaPacketFilterTypeOperation.Greater )
                    {
                        UInt64 compareWith = (UInt64) _Value;

                        if ( actualValue > compareWith )
                            return true;
                    }
                    else if ( Operation == UltimaPacketFilterTypeOperation.Lesser )
                    {
                        UInt64 compareWith = (UInt64) _Value;

                        if ( actualValue < compareWith )
                            return true;
                    }
                    else if ( Operation == UltimaPacketFilterTypeOperation.In )
                    {
                        List<UInt64> list = (List<UInt64>) _Value;

                        foreach ( UInt64 v in list )
                            if ( actualValue == v )
                                return true;
                    }

                    return false;
                }
            }

            return false;
        }
Ejemplo n.º 27
0
 public QueryPropertiesItem(UltimaPacket parent, uint serial)
 {
     _Parent = parent;
     _Serial = serial;
 }
Ejemplo n.º 28
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;
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Determines whether packet is displayed.
        /// </summary>
        /// <param name="packet">Packet to check.</param>
        /// <returns>True if displayed, false otherwise.</returns>
        public bool IsDisplayed(UltimaPacket packet)
        {
            object value = Definition.Getter(packet);

            switch (_Code)
            {
            case TypeCode.Boolean:
            {
                Boolean actualValue = (Boolean)value;

                if (Operation == UltimaPacketFilterTypeOperation.In)
                {
                    List <Boolean> list = (List <Boolean>)_Value;

                    foreach (Boolean v in list)
                    {
                        if (actualValue == v)
                        {
                            return(true);
                        }
                    }
                }

                return(false);
            }

            case TypeCode.Byte:
            {
                Byte actualValue = (Byte)value;

                if (Operation == UltimaPacketFilterTypeOperation.Greater)
                {
                    Byte compareWith = (Byte)_Value;

                    if (actualValue > compareWith)
                    {
                        return(true);
                    }
                }
                else if (Operation == UltimaPacketFilterTypeOperation.Lesser)
                {
                    Byte compareWith = (Byte)_Value;

                    if (actualValue < compareWith)
                    {
                        return(true);
                    }
                }
                else if (Operation == UltimaPacketFilterTypeOperation.In)
                {
                    List <Byte> list = (List <Byte>)_Value;

                    foreach (Byte v in list)
                    {
                        if (actualValue == v)
                        {
                            return(true);
                        }
                    }
                }

                return(false);
            }

            case TypeCode.Char:
            {
                Char actualValue = (Char)value;

                if (Operation == UltimaPacketFilterTypeOperation.Greater)
                {
                    Char compareWith = (Char)_Value;

                    if (actualValue > compareWith)
                    {
                        return(true);
                    }
                }
                else if (Operation == UltimaPacketFilterTypeOperation.Lesser)
                {
                    Char compareWith = (Char)_Value;

                    if (actualValue < compareWith)
                    {
                        return(true);
                    }
                }
                else if (Operation == UltimaPacketFilterTypeOperation.In)
                {
                    List <Char> list = (List <Char>)_Value;

                    foreach (Char v in list)
                    {
                        if (actualValue == v)
                        {
                            return(true);
                        }
                    }
                }

                return(false);
            }

            case TypeCode.Decimal:
            {
                Decimal actualValue = (Decimal)value;

                if (Operation == UltimaPacketFilterTypeOperation.Greater)
                {
                    Decimal compareWith = (Decimal)_Value;

                    if (actualValue > compareWith)
                    {
                        return(true);
                    }
                }
                else if (Operation == UltimaPacketFilterTypeOperation.Lesser)
                {
                    Decimal compareWith = (Decimal)_Value;

                    if (actualValue < compareWith)
                    {
                        return(true);
                    }
                }
                else if (Operation == UltimaPacketFilterTypeOperation.In)
                {
                    List <Decimal> list = (List <Decimal>)_Value;

                    foreach (Decimal v in list)
                    {
                        if (actualValue == v)
                        {
                            return(true);
                        }
                    }
                }

                return(false);
            }

            case TypeCode.Double:
            {
                Double actualValue = (Double)value;

                if (Operation == UltimaPacketFilterTypeOperation.Greater)
                {
                    Double compareWith = (Double)_Value;

                    if (actualValue > compareWith)
                    {
                        return(true);
                    }
                }
                else if (Operation == UltimaPacketFilterTypeOperation.Lesser)
                {
                    Double compareWith = (Double)_Value;

                    if (actualValue < compareWith)
                    {
                        return(true);
                    }
                }
                else if (Operation == UltimaPacketFilterTypeOperation.In)
                {
                    List <Double> list = (List <Double>)_Value;

                    foreach (Double v in list)
                    {
                        if (actualValue == v)
                        {
                            return(true);
                        }
                    }
                }

                return(false);
            }

            case TypeCode.Int16:
            {
                Int16 actualValue = (Int16)value;

                if (Operation == UltimaPacketFilterTypeOperation.Greater)
                {
                    Int16 compareWith = (Int16)_Value;

                    if (actualValue > compareWith)
                    {
                        return(true);
                    }
                }
                else if (Operation == UltimaPacketFilterTypeOperation.Lesser)
                {
                    Int16 compareWith = (Int16)_Value;

                    if (actualValue < compareWith)
                    {
                        return(true);
                    }
                }
                else if (Operation == UltimaPacketFilterTypeOperation.In)
                {
                    List <Int16> list = (List <Int16>)_Value;

                    foreach (Int16 v in list)
                    {
                        if (actualValue == v)
                        {
                            return(true);
                        }
                    }
                }

                return(false);
            }

            case TypeCode.Int32:
            {
                Int32 actualValue = (Int32)value;

                if (Operation == UltimaPacketFilterTypeOperation.Greater)
                {
                    Int32 compareWith = (Int32)_Value;

                    if (actualValue > compareWith)
                    {
                        return(true);
                    }
                }
                else if (Operation == UltimaPacketFilterTypeOperation.Lesser)
                {
                    Int32 compareWith = (Int32)_Value;

                    if (actualValue < compareWith)
                    {
                        return(true);
                    }
                }
                else if (Operation == UltimaPacketFilterTypeOperation.In)
                {
                    List <Int32> list = (List <Int32>)_Value;

                    foreach (Int32 v in list)
                    {
                        if (actualValue == v)
                        {
                            return(true);
                        }
                    }
                }

                return(false);
            }

            case TypeCode.Int64:
            {
                Int64 actualValue = (Int64)value;

                if (Operation == UltimaPacketFilterTypeOperation.Greater)
                {
                    Int64 compareWith = (Int64)_Value;

                    if (actualValue > compareWith)
                    {
                        return(true);
                    }
                }
                else if (Operation == UltimaPacketFilterTypeOperation.Lesser)
                {
                    Int64 compareWith = (Int64)_Value;

                    if (actualValue < compareWith)
                    {
                        return(true);
                    }
                }
                else if (Operation == UltimaPacketFilterTypeOperation.In)
                {
                    List <Int64> list = (List <Int64>)_Value;

                    foreach (Int64 v in list)
                    {
                        if (actualValue == v)
                        {
                            return(true);
                        }
                    }
                }

                return(false);
            }

            case TypeCode.SByte:
            {
                SByte actualValue = (SByte)value;

                if (Operation == UltimaPacketFilterTypeOperation.Greater)
                {
                    SByte compareWith = (SByte)_Value;

                    if (actualValue > compareWith)
                    {
                        return(true);
                    }
                }
                else if (Operation == UltimaPacketFilterTypeOperation.Lesser)
                {
                    SByte compareWith = (SByte)_Value;

                    if (actualValue < compareWith)
                    {
                        return(true);
                    }
                }
                else if (Operation == UltimaPacketFilterTypeOperation.In)
                {
                    List <SByte> list = (List <SByte>)_Value;

                    foreach (SByte v in list)
                    {
                        if (actualValue == v)
                        {
                            return(true);
                        }
                    }
                }

                return(false);
            }

            case TypeCode.Single:
            {
                Single actualValue = (Single)value;

                if (Operation == UltimaPacketFilterTypeOperation.Greater)
                {
                    Single compareWith = (Single)_Value;

                    if (actualValue > compareWith)
                    {
                        return(true);
                    }
                }
                else if (Operation == UltimaPacketFilterTypeOperation.Lesser)
                {
                    Single compareWith = (Single)_Value;

                    if (actualValue < compareWith)
                    {
                        return(true);
                    }
                }
                else if (Operation == UltimaPacketFilterTypeOperation.In)
                {
                    List <Single> list = (List <Single>)_Value;

                    foreach (Single v in list)
                    {
                        if (actualValue == v)
                        {
                            return(true);
                        }
                    }
                }

                return(false);
            }

            case TypeCode.String:
            {
                String actualValue = ((String)value).ToLower();

                if (Operation == UltimaPacketFilterTypeOperation.Contains)
                {
                    List <String> list = (List <String>)_Value;

                    foreach (String v in list)
                    {
                        if (actualValue.Contains(v))
                        {
                            return(true);
                        }
                    }
                }
                else if (Operation == UltimaPacketFilterTypeOperation.In)
                {
                    List <String> list = (List <String>)_Value;

                    foreach (String v in list)
                    {
                        if (actualValue == v)
                        {
                            return(true);
                        }
                    }
                }

                return(false);
            }

            case TypeCode.UInt16:
            {
                UInt16 actualValue = (UInt16)value;

                if (Operation == UltimaPacketFilterTypeOperation.Greater)
                {
                    UInt16 compareWith = (UInt16)_Value;

                    if (actualValue > compareWith)
                    {
                        return(true);
                    }
                }
                else if (Operation == UltimaPacketFilterTypeOperation.Lesser)
                {
                    UInt16 compareWith = (UInt16)_Value;

                    if (actualValue < compareWith)
                    {
                        return(true);
                    }
                }
                else if (Operation == UltimaPacketFilterTypeOperation.In)
                {
                    List <UInt16> list = (List <UInt16>)_Value;

                    foreach (UInt16 v in list)
                    {
                        if (actualValue == v)
                        {
                            return(true);
                        }
                    }
                }

                return(false);
            }

            case TypeCode.UInt32:
            {
                UInt32 actualValue = (UInt32)value;

                if (Operation == UltimaPacketFilterTypeOperation.Greater)
                {
                    UInt32 compareWith = (UInt32)_Value;

                    if (actualValue > compareWith)
                    {
                        return(true);
                    }
                }
                else if (Operation == UltimaPacketFilterTypeOperation.Lesser)
                {
                    UInt32 compareWith = (UInt32)_Value;

                    if (actualValue < compareWith)
                    {
                        return(true);
                    }
                }
                else if (Operation == UltimaPacketFilterTypeOperation.In)
                {
                    List <UInt32> list = (List <UInt32>)_Value;

                    foreach (UInt32 v in list)
                    {
                        if (actualValue == v)
                        {
                            return(true);
                        }
                    }
                }

                return(false);
            }

            case TypeCode.UInt64:
            {
                UInt64 actualValue = (UInt64)value;

                if (Operation == UltimaPacketFilterTypeOperation.Greater)
                {
                    UInt64 compareWith = (UInt64)_Value;

                    if (actualValue > compareWith)
                    {
                        return(true);
                    }
                }
                else if (Operation == UltimaPacketFilterTypeOperation.Lesser)
                {
                    UInt64 compareWith = (UInt64)_Value;

                    if (actualValue < compareWith)
                    {
                        return(true);
                    }
                }
                else if (Operation == UltimaPacketFilterTypeOperation.In)
                {
                    List <UInt64> list = (List <UInt64>)_Value;

                    foreach (UInt64 v in list)
                    {
                        if (actualValue == v)
                        {
                            return(true);
                        }
                    }
                }

                return(false);
            }
            }

            return(false);
        }