Exemple #1
0
        private void FileLoadingCallback(string line, long position)
        {
            if ((int)((DamageProcessor.Size() + HealingProcessor.Size() + MiscProcessor.Size() + CastProcessor.Size()) / 10000) is int sleep && sleep > 10)
            {
                Thread.Sleep(4 * (sleep - 10));
            }

            Interlocked.Exchange(ref FilePosition, position);
            Interlocked.Add(ref LineCount, 1);

            if (PreLineParser.NeedProcessing(line, out string action))
            {
                var lineData = new LineData()
                {
                    Line = line, LineNumber = LineCount, Action = action
                };

                // avoid having other things parse chat by accident
                if (ChatLineParser.Process(lineData) is ChatType chatType)
                {
                    PlayerChatManager.Add(chatType);
                }
                else if (CurrentLogOption != LogOption.ARCHIVE)
                {
                    // 4 is for the number of processors
                    DebugUtil.RegisterLine(LineCount, line, 4);
                    CastProcessor.Add(lineData);
                    DamageProcessor.Add(lineData);
                    HealingProcessor.Add(lineData);
                    MiscProcessor.Add(lineData);
                }
            }
        }
Exemple #2
0
        private ChatType GetNextChat()
        {
            ChatType result = null;

            if (CurrentArchive == null && Months != null && CurrentMonth < Months.Count)
            {
                CurrentArchive = GetArchive();
            }
            else if (CurrentArchive == null && Months != null && CurrentMonth >= Months.Count)
            {
                if (GetNextYear())
                {
                    return(GetNextChat());
                }
            }

            if (CurrentArchive != null && CurrentReader == null)
            {
                CurrentReader = GetNextReader();
                if (CurrentReader == null)
                {
                    CurrentMonth++;
                    CurrentArchive = null;
                    return(GetNextChat());
                }
            }

            if (CurrentReader != null)
            {
                result = END_RESULT;
                string nextLine;
                while (result == END_RESULT && (nextLine = CurrentReader.ReadLine()) != null)
                {
                    var chatType = ChatLineParser.ParseChatType(nextLine);
                    if (chatType != null && chatType.Line.Length > 0)
                    {
                        // fix  % chars
                        chatType.Line = chatType.Line.Replace("&PCT;", "%");
                    }

                    result = CurrentChatFilter.PassFilter(chatType) ? chatType : result;
                }

                if (result == END_RESULT)
                {
                    CurrentReader.Close();
                    CurrentReader = null;
                    return(GetNextChat());
                }
            }

            return(result);
        }