Ejemplo n.º 1
0
        public void AddPacketToListView(PacketEntry item, bool silent = false)
        {
            if (item.Direction == "S")
            {
                item.Name    = _db.GetServerZoneOpName(int.Parse(item.Message, NumberStyles.HexNumber));
                item.Comment = _db.GetServerZoneOpComment(int.Parse(item.Message, NumberStyles.HexNumber));
            }
            else
            {
                item.Name    = _db.GetClientZoneOpName(int.Parse(item.Message, NumberStyles.HexNumber));
                item.Comment = _db.GetClientZoneOpComment(int.Parse(item.Message, NumberStyles.HexNumber));
            }

            item.Category = item.Set.ToString();

            if (item.Message == "0142" || item.Message == "0143" || item.Message == "0144")
            {
                int cat = BitConverter.ToUInt16(item.Data, 0x20);
                item.ActorControl = cat;
                item.Name         = _db.GetActorControlTypeName(cat);
            }

            if (_mainWindow.RunScriptsOnNewCheckBox.IsChecked)
            {
                try
                {
                    PacketEventArgs args = null;

                    var structText = _db.GetServerZoneStruct(int.Parse(item.Message, NumberStyles.HexNumber));

                    if (structText != null)
                    {
                        if (structText.Length != 0)
                        {
                            var structProvider = new Struct();
                            var structEntries  = structProvider.Parse(structText, item.Data);

                            args = new PacketEventArgs(item, structEntries.Item2, _mainWindow.ScriptDebugView);
                        }
                    }
                    else
                    {
                        args = new PacketEventArgs(item, null, _mainWindow.ScriptDebugView);
                    }

                    Scripting_RunOnPacket(args);
                }
                catch (Exception exc)
                {
                    new ExtendedErrorView(
                        $"Scripting exception thrown for {item.Message} - {item.Name}. Turning off auto script running.", exc.ToString(), "Error").ShowDialog();
                    _mainWindow.RunScriptsOnNewCheckBox.IsChecked = false;
                    return;
                }
            }

            if (_mainWindow.ExEnabledCheckbox.IsChecked && item.Direction == "S")
            {
                try
                {
                    var structText = _db.GetServerZoneStruct(int.Parse(item.Message, NumberStyles.HexNumber));

                    if (structText != null)
                    {
                        if (structText.Length != 0)
                        {
                            switch (item.Name)
                            {
                            case "NpcSpawn":
                            {
                                Struct  structProvider = new Struct();
                                dynamic obj            = structProvider.Parse(structText, item.Data).Item2;

                                item.Comment =
                                    $"Name: {_mainWindow.ExdProvider.GetBnpcName((int)obj.bNPCName)}({obj.bNPCName})";
                            }
                            break;

                            case "ActorCast":
                            {
                                Struct  structProvider = new Struct();
                                dynamic obj            = structProvider.Parse(structText, item.Data).Item2;

                                item.Comment = $"Action: {_mainWindow.ExdProvider.GetActionName(obj.action_id)}({obj.action_id}) - Type {obj.skillType} - Cast Time: {obj.cast_time}";
                            }
                            break;
                            }

                            if (item.Name.Contains("ActorControl"))
                            {
                                switch (item.ActorControl)
                                {
                                case 3:     //CastStart
                                {
                                    var ctrl = Util.FastParseActorControl(item.Data);

                                    item.Comment = $"Action: {_mainWindow.ExdProvider.GetActionName((int)ctrl.Param2)}({ctrl.Param2}) - Type {ctrl.Param1}";
                                }
                                break;

                                case 17:     //ActionStart
                                {
                                    var ctrl = Util.FastParseActorControl(item.Data);

                                    item.Comment = $"Action: {_mainWindow.ExdProvider.GetActionName((int)ctrl.Param2)}({ctrl.Param2}) - Type {ctrl.Param1}";
                                }
                                break;
                                }
                            }
                        }
                    }
                }
                catch (Exception exc)
                {
                    new ExtendedErrorView(
                        $"EXD Error for {item.Message} - {item.Name}. Turning off EXD features.", exc.ToString(), "Error").ShowDialog();
                    _mainWindow.ExEnabledCheckbox.IsChecked = false;
                }
            }

            PacketListView.Items.Add(item);

            if (!silent)
            {
                UpdateInfoLabel();
            }
        }
Ejemplo n.º 2
0
        public void AddPacketToListView(PacketEntry item, bool silent = false)
        {
            if (_mainWindow.IsPausedCheckBox.IsChecked && !silent)
            {
                return;
            }

            if (_encryptionProvider != null && !item.IsDecrypted && item.Data[0x0C] != 0x09 && item.Data[0x0C] != 0x07 && item.Connection == FFXIVNetworkMonitor.ConnectionType.Lobby)
            {
                var data = item.Data;
                _encryptionProvider.DecryptPacket(ref data);
                item.Data = data;

                item.Message = BitConverter.ToUInt16(item.Data, 0x12).ToString("X4");

                item.IsDecrypted = true;
            }

            if (item.Direction == "S")
            {
                item.Name    = _db.GetServerZoneOpName(int.Parse(item.Message, NumberStyles.HexNumber));
                item.Comment = _db.GetServerZoneOpComment(int.Parse(item.Message, NumberStyles.HexNumber));

                switch (item.Message)
                {
                case "0142":
                case "0143":
                case "0144":
                    int cat = BitConverter.ToUInt16(item.Data, 0x20);
                    item.ActorControl = cat;
                    item.Name         = _db.GetActorControlTypeName(cat);
                    break;
                }

                if (_mainWindow.ExEnabledCheckbox.IsChecked)
                {
                    try
                    {
                        var structText = _db.GetServerZoneStruct(int.Parse(item.Message, NumberStyles.HexNumber));

                        if (structText != null && structText.Length != 0)
                        {
                            switch (item.Name)
                            {
                            case "NpcSpawn":
                            {
                                Struct  structProvider = new Struct();
                                dynamic obj            = structProvider.Parse(structText, item.Data).Item2;

                                item.Comment =
                                    $"Name: {_mainWindow.ExdProvider.GetBnpcName((int)obj.bNPCName)}({obj.bNPCName}) - Base: {obj.bNPCBase}";
                            }
                            break;

                            case "ActorCast":
                            {
                                Struct  structProvider = new Struct();
                                dynamic obj            = structProvider.Parse(structText, item.Data).Item2;

                                item.Comment = $"Action: {_mainWindow.ExdProvider.GetActionName(obj.action_id)}({obj.action_id}) - Type {obj.skillType} - Cast Time: {obj.cast_time}";
                            }
                            break;
                            }

                            if (item.Name.Contains("ActorControl"))
                            {
                                switch (item.ActorControl)
                                {
                                case 3:     //CastStart
                                {
                                    var ctrl = Util.FastParseActorControl(item.Data);

                                    item.Comment = $"Action: {_mainWindow.ExdProvider.GetActionName((int)ctrl.Param2)}({ctrl.Param2}) - Type {ctrl.Param1}";
                                }
                                break;

                                case 17:     //ActionStart
                                {
                                    var ctrl = Util.FastParseActorControl(item.Data);

                                    item.Comment = $"Action: {_mainWindow.ExdProvider.GetActionName((int)ctrl.Param2)}({ctrl.Param2}) - Type {ctrl.Param1}";
                                }
                                break;
                                }
                            }
                        }
                    }
                    catch (Exception exc)
                    {
                        new ExtendedErrorView(
                            $"EXD Error for {item.Message} - {item.Name}. Turning off EXD features.", exc.ToString(), "Error").ShowDialog();
                        _mainWindow.ExEnabledCheckbox.IsChecked = false;
                    }
                }
            }
            else
            {
                item.Name    = _db.GetClientZoneOpName(int.Parse(item.Message, NumberStyles.HexNumber));
                item.Comment = _db.GetClientZoneOpComment(int.Parse(item.Message, NumberStyles.HexNumber));

                if (item.Data[0x0C] == 0x09 && item.Message == "0000" && item.Connection == FFXIVNetworkMonitor.ConnectionType.Lobby)
                {
                    _encryptionProvider = new LobbyEncryptionProvider(item.Data);

                    item.Comment = "Lobby Encryption INIT: " + Util.ByteArrayToString(_encryptionProvider.EncKey);
                }
            }

            item.IsForSelf = BitConverter.ToUInt32(item.Data, 0x04) == BitConverter.ToUInt32(item.Data, 0x08);
            item.Category  = item.Set.ToString();

            if (_mainWindow.RunScriptsOnNewCheckBox.IsChecked)
            {
                if (_mainWindow.ScriptProvider == null)
                {
                    MessageBox.Show("No scripts were loaded.", "Error", MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                    _mainWindow.RunScriptsOnNewCheckBox.IsChecked = false;
                }
                else
                {
                    try
                    {
                        Scripting_RunOnPacket(item, _mainWindow.ScriptProvider);
                    }
                    catch (Exception exc)
                    {
                        new ExtendedErrorView(
                            $"Scripting exception thrown for {item.Message} - {item.Name}. Turning off auto script running.", exc.ToString(), "Error").ShowDialog();
                        _mainWindow.RunScriptsOnNewCheckBox.IsChecked = false;
                    }
                }
            }

            if (_filters != null && _filters.Length > 0)
            {
                foreach (var filterEntry in _filters)
                {
                    if (!filterEntry.IsApplicableForFilterSet(item))
                    {
                        return;
                    }
                }
            }

            PacketListView.Items.Add(item);

            if (!silent)
            {
                UpdateInfoLabel();
            }
        }
Ejemplo n.º 3
0
        public void AddPacketToListView(PacketListItem item)
        {
            if (item.DirectionCol == "S")
            {
                item.NameCol    = _db.GetServerZoneOpName(int.Parse(item.MessageCol, NumberStyles.HexNumber));
                item.CommentCol = _db.GetServerZoneOpComment(int.Parse(item.MessageCol, NumberStyles.HexNumber));
            }
            else
            {
                item.NameCol    = _db.GetClientZoneOpName(int.Parse(item.MessageCol, NumberStyles.HexNumber));
                item.CommentCol = _db.GetClientZoneOpComment(int.Parse(item.MessageCol, NumberStyles.HexNumber));
            }

            item.CategoryCol = item.Set.ToString();

            if (item.MessageCol == "0142" || item.MessageCol == "0143" || item.MessageCol == "0144")
            {
                int cat = BitConverter.ToUInt16(item.Data, 0x20);
                item.ActorControl = cat;
                item.NameCol      = _db.GetActorControlTypeName(cat);
            }

            if (_mainWindow.RunScriptsOnNewCheckBox.IsChecked)
            {
                try
                {
                    PacketEventArgs args = null;

                    var structText = _db.GetServerZoneStruct(int.Parse(item.MessageCol, NumberStyles.HexNumber));

                    if (structText != null)
                    {
                        if (structText.Length != 0)
                        {
                            var structProvider = new Struct();
                            var structEntries  = structProvider.Parse(structText, item.Data);

                            args = new PacketEventArgs(item, structEntries.Item2, _mainWindow.ScriptDebugView);
                        }
                    }
                    else
                    {
                        args = new PacketEventArgs(item, null, _mainWindow.ScriptDebugView);
                    }

                    Scripting_RunOnPacket(args);
                }
                catch (Exception exc)
                {
                    MessageBox.Show(
                        $"[XivMonTab] Script error!\n\n{exc}",
                        "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    _mainWindow.RunScriptsOnNewCheckBox.IsChecked = false;
                    return;
                }
            }

            if (_mainWindow.ExEnabledCheckbox.IsChecked && item.DirectionCol == "S")
            {
                try
                {
                    var structText = _db.GetServerZoneStruct(int.Parse(item.MessageCol, NumberStyles.HexNumber));

                    if (structText != null)
                    {
                        if (structText.Length != 0)
                        {
                            switch (item.NameCol)
                            {
                            case "NpcSpawn":
                            {
                                Struct  structProvider = new Struct();
                                dynamic obj            = structProvider.Parse(structText, item.Data).Item2;

                                item.CommentCol =
                                    $"Name: {_mainWindow.ExdProvider.GetBnpcName((int)obj.bNPCName)}({obj.bNPCName})";
                            }
                            break;

                            case "ActorCast":
                            {
                                Struct  structProvider = new Struct();
                                dynamic obj            = structProvider.Parse(structText, item.Data).Item2;

                                item.CommentCol = $"Action: {_mainWindow.ExdProvider.GetActionName(obj.action_id)}({obj.action_id}) - Type {obj.skillType} - Cast Time: {obj.cast_time}";
                            }
                            break;
                            }

                            if (item.NameCol.Contains("ActorControl"))
                            {
                                switch (item.ActorControl)
                                {
                                case 3:     //CastStart
                                {
                                    var ctrl = Util.FastParseActorControl(item.Data);

                                    item.CommentCol = $"Action: {_mainWindow.ExdProvider.GetActionName((int)ctrl.Param2)}({ctrl.Param2}) - Type {ctrl.Param1}";
                                }
                                break;

                                case 17:     //ActionStart
                                {
                                    var ctrl = Util.FastParseActorControl(item.Data);

                                    item.CommentCol = $"Action: {_mainWindow.ExdProvider.GetActionName((int)ctrl.Param2)}({ctrl.Param2}) - Type {ctrl.Param1}";
                                }
                                break;
                                }
                            }
                        }
                    }
                }
                catch (Exception exc)
                {
                    MessageBox.Show(
                        $"[XivMonTab] EXD error for {item.MessageCol} - {item.NameCol}!\n\n{exc}",
                        "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    _mainWindow.ExEnabledCheckbox.IsChecked = false;
                }
            }

            PacketListView.Items.Add(item);

            UpdateInfoLabel();
        }