private static bool OnLocalizedMessageAffix(ref byte[] packet, ref int length)
        {
            PacketReader reader = new PacketReader(packet, length, false);

            int              serial      = reader.ReadInt32();
            int              graphic     = reader.ReadInt16();
            JournalSpeech    messageType = (JournalSpeech)reader.ReadByte();
            int              hue         = reader.ReadInt16();
            int              font        = reader.ReadInt16();
            int              cliloc      = reader.ReadInt32();
            MessageAffixType affixType   = (MessageAffixType)reader.ReadByte();
            string           name        = reader.ReadString(30);
            string           affix       = reader.ReadString();

            string[] arguments = reader.ReadUnicodeString()
                                 .Split(new[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);

            JournalEntry journalEntry = new JournalEntry
            {
                Serial     = serial,
                ID         = graphic,
                SpeechType = messageType,
                SpeechHue  = hue,
                SpeechFont = font,
                Cliloc     = cliloc,
                Name       = name,
                Arguments  = arguments
            };

            string text = Cliloc.GetLocalString(journalEntry.Cliloc, journalEntry.Arguments);

            if (affixType.HasFlag(MessageAffixType.Prepend))
            {
                journalEntry.Text = $"{affix}{text}";
            }
            else if (affixType.HasFlag(MessageAffixType.Append))
            {
                journalEntry.Text = $"{text}{affix}";
            }

            bool block = RepeatedMessagesFilter.CheckMessage(journalEntry);

            if (block && RepeatedMessagesFilter.FilterOptions.SendToJournal)
            {
                IncomingPacketHandlers.AddToJournal(journalEntry);
            }

            return(block || ClilocFilter.CheckMessageAffix(journalEntry, affixType, affix));
        }
Beispiel #2
0
        private static void OnLocalizedTextAffix(PacketReader reader)
        {
            int              serial      = reader.ReadInt32();
            int              graphic     = reader.ReadInt16();
            JournalSpeech    messageType = (JournalSpeech)reader.ReadByte();
            int              hue         = reader.ReadInt16();
            int              font        = reader.ReadInt16();
            int              cliloc      = reader.ReadInt32();
            MessageAffixType affixType   = (MessageAffixType)reader.ReadByte();
            string           name        = reader.ReadString(30);
            string           affix       = reader.ReadString();

            string[] arguments = reader.ReadUnicodeString()
                                 .Split(new[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);

            JournalEntry journalEntry = new JournalEntry
            {
                Serial     = serial,
                ID         = graphic,
                SpeechType = messageType,
                SpeechHue  = hue,
                SpeechFont = font,
                Cliloc     = cliloc,
                Name       = name,
                Arguments  = arguments
            };

            string text = Cliloc.GetLocalString(journalEntry.Cliloc, journalEntry.Arguments);

            if (affixType.HasFlag(MessageAffixType.Prepend))
            {
                journalEntry.Text = $"{affix}{text}";
            }
            else if (affixType.HasFlag(MessageAffixType.Append))
            {
                journalEntry.Text = $"{text}{affix}";
            }

            Engine.Journal.Write(journalEntry);
            JournalEntryAddedEvent?.Invoke(journalEntry);
        }
        public static bool CheckMessageAffix(JournalEntry journalEntry, MessageAffixType affixType, string affix)
        {
            if (!IsEnabled || journalEntry.Cliloc == 0)
            {
                return(false);
            }

            if (Filters.All(f => f.Key != journalEntry.Cliloc))
            {
                return(false);
            }

            KeyValuePair <int, string> match = Filters.FirstOrDefault(f => f.Key == journalEntry.Cliloc);

            string text = affixType.HasFlag(MessageAffixType.Prepend)
                ? $"{affix}{match.Value}"
                : $"{match.Value}{affix}";

            Engine.SendPacketToClient(new UnicodeText(journalEntry.Serial, journalEntry.ID, JournalSpeech.Say,
                                                      journalEntry.SpeechHue, journalEntry.SpeechFont, Strings.UO_LOCALE, journalEntry.Name, text));

            return(true);
        }