Esempio n. 1
0
        /// <summary>
        /// ログ行を分析する
        /// </summary>
        /// <param name="logLine">ログ行</param>
        private void AnalyzeLogLine(
            LogLineEventArgs logLine)
        {
            if (logLine == null)
            {
                return;
            }

            // ログを分類する
            var category = analyzeLogLine(logLine.logLine, ConstantKeywords.Keywords);

            switch (category)
            {
            case KewordTypes.Record:
                if (this.inCombat)
                {
                    this.StoreRecordLog(logLine);
                }
                break;

            case KewordTypes.Pet:
                break;

            case KewordTypes.Cast:
                if (this.inCombat)
                {
                    this.StoreCastLog(logLine);
                }
                break;

            case KewordTypes.CastStartsUsing:
                /*
                 * starts using は準備動作をかぶるので無視する
                 * if (this.inCombat)
                 * {
                 *  this.StoreCastStartsUsingLog(log);
                 * }
                 */
                break;

            case KewordTypes.Action:
                if (this.inCombat)
                {
                    this.StoreActionLog(logLine);
                }
                break;

            case KewordTypes.Effect:
                if (this.inCombat)
                {
                    this.StoreEffectLog(logLine);
                }
                break;

            case KewordTypes.Marker:
                if (this.inCombat)
                {
                    this.StoreMarkerLog(logLine);
                }
                break;

            case KewordTypes.HPRate:
                if (this.inCombat)
                {
                    this.StoreHPRateLog(logLine);
                }
                break;

            case KewordTypes.Added:
                if (this.inCombat)
                {
                    this.StoreAddedLog(logLine);
                }
                break;

            case KewordTypes.Dialogue:
                if (this.inCombat)
                {
                    this.StoreDialog(logLine);
                }
                break;

            case KewordTypes.Start:
                lock (this.CurrentCombatLogList)
                {
                    if (!this.inCombat)
                    {
                        if (!this.isImporting)
                        {
                            this.CurrentCombatLogList.Clear();
                            this.ActorHPRate.Clear();
                            this.partyNames = null;
                            this.combatants = null;
                            this.no         = 1;
                        }

                        Logger.Write("Start Combat");

                        // 自分の座標をダンプする
                        LogBuffer.DumpPosition(true);
                    }

                    this.inCombat = true;
                }

                this.StoreStartCombat(logLine);
                break;

            case KewordTypes.End:
                lock (this.CurrentCombatLogList)
                {
                    if (this.inCombat)
                    {
                        this.inCombat = false;
                        this.StoreEndCombat(logLine);

                        this.AutoSaveToSpreadsheet();

                        Logger.Write("End Combat");
                    }
                }
                break;

            default:
                break;
            }

            KewordTypes analyzeLogLine(string log, IList <AnalyzeKeyword> keywords)
            {
                var key = (
                    from x in keywords
                    where
                    log.ContainsIgnoreCase(x.Keyword)
                    select
                    x).FirstOrDefault();

                return(key != null ?
                       key.Category :
                       KewordTypes.Unknown);
            }
        }
Esempio n. 2
0
        private void TryCompile()
        {
            lock (this)
            {
                if ((DateTime.Now - this.lastQueueTimestamp).TotalMilliseconds <= CompileHandlerInterval)
                {
                    return;
                }

                this.lastQueueTimestamp = DateTime.MaxValue;

                this.RefreshCombatants();

                var isSimulationChanged = false;

                if (this.previousInSimulation != this.InSimulation)
                {
                    this.previousInSimulation = this.InSimulation;
                    isSimulationChanged       = true;
                }

                if (isSimulationChanged || this.isQueueRecompile)
                {
                    if (this.isQueueRecompile)
                    {
                        this.RefreshPlayerPlacceholder();
                        this.RefreshPartyPlaceholders();
                        this.RefreshPetPlaceholder();
                    }

                    this.RecompileSpells();
                    this.RecompileTickers();

                    var fromEvent = isSimulationChanged ? "simulation changed" : "condition changed";
                    Logger.Write($"recompiled triggers on {fromEvent}");

                    TickersController.Instance.GarbageWindows(this.TickerList);
                    SpellsController.Instance.GarbageSpellPanelWindows(this.SpellList);

                    this.CompileConditionChanged?.Invoke(this, new EventArgs());

                    this.isQueueRecompile = false;
                }

                if (this.isQueueZoneChange)
                {
                    // チャットログをフラッシュする
                    ParsedLogWorker.Instance.Flush(true);

                    // インスタンススペルを消去する
                    SpellTable.Instance.RemoveInstanceSpellsAll();

                    // 設定を保存する
                    PluginCore.Instance?.SaveSettingsAsync();

                    var zone   = ActGlobals.oFormActMain.CurrentZone;
                    var zoneID = XIVPluginHelper.Instance?.GetCurrentZoneID();
                    Logger.Write($"zone changed. zone={ActGlobals.oFormActMain.CurrentZone}, zone_id={XIVPluginHelper.Instance?.GetCurrentZoneID()}");
                    this.ZoneChanged?.Invoke(this, new EventArgs());

                    Task.Run(() =>
                    {
                        Thread.Sleep(TimeSpan.FromSeconds(6));

                        // 自分の座標をダンプする
                        LogBuffer.DumpPosition(true);

                        // ETを出力する
                        var nowET = EorzeaTime.Now;
                        LogParser.RaiseLog(
                            DateTime.Now,
                            $"[EX] ZoneChanged ET{nowET.Hour:00}:00 Zone:{zoneID:000} {zone}");
                    });

                    this.isQueueZoneChange = false;
                }
            }
        }
        private void DoWork()
        {
            try
            {
                lock (this)
                {
                    this.RefreshCombatants();

                    var isPlayerChanged = this.IsPlayerChanged();
                    var isPartyChanged  = this.IsPartyChanged();
                    var isZoneChanged   = this.IsZoneChanged();

                    if (isPlayerChanged)
                    {
                        this.RefreshPlayerPlacceholder();
                    }

                    if (isZoneChanged ||
                        isPartyChanged)
                    {
                        this.RefreshPartyPlaceholders();
                        this.RefreshPetPlaceholder();
                    }

                    if (isPlayerChanged ||
                        isPartyChanged ||
                        isZoneChanged)
                    {
                        this.RecompileSpells();
                        this.RecompileTickers();

                        TickersController.Instance.GarbageWindows(this.TickerList);
                        SpellsController.Instance.GarbageSpellPanelWindows(this.SpellList);

                        this.CompileConditionChanged?.Invoke(this, new EventArgs());
                    }

                    if (isZoneChanged)
                    {
                        // インスタンススペルを消去する
                        SpellTable.Instance.RemoveInstanceSpellsAll();

                        var zone = ActGlobals.oFormActMain.CurrentZone;
                        Logger.Write($"zone changed. zone={zone}");
                        this.ZoneChanged?.Invoke(this, new EventArgs());

                        // 自分の座標をダンプする
                        Task.Run(() =>
                        {
                            Thread.Sleep(TimeSpan.FromSeconds(5));
                            LogBuffer.DumpPosition(true);
                        });
                    }

                    // 定期的に自分の座標をダンプする
                    if ((DateTime.Now - this.lastDumpPositionTimestamp).TotalSeconds >= 60.0)
                    {
                        LogBuffer.DumpPosition(true);
                        this.lastDumpPositionTimestamp = DateTime.Now;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Write("table compiler error:", ex);
            }
        }
Esempio n. 4
0
        private void DoWork()
        {
            try
            {
                lock (this)
                {
                    this.RefreshCombatants();

                    var isSimulationChanged = false;

                    if (this.previousInSimulation != this.InSimulation)
                    {
                        this.previousInSimulation = this.InSimulation;
                        isSimulationChanged       = true;
                    }

                    if (this.isPartyChanged ||
                        this.isZoneChanged)
                    {
                        this.RefreshPlayerPlacceholder();
                        this.RefreshPartyPlaceholders();
                        this.RefreshPetPlaceholder();
                    }

                    if (isSimulationChanged ||
                        this.isPartyChanged ||
                        this.isZoneChanged)
                    {
                        this.RecompileSpells();
                        this.RecompileTickers();

                        var fromEvent =
                            isSimulationChanged ? "simulation changed" :
                            this.isPartyChanged ? "party changed" :
                            this.isZoneChanged ? "zone changed" : string.Empty;
                        Logger.Write($"recompiled triggers on {fromEvent}");

                        TickersController.Instance.GarbageWindows(this.TickerList);
                        SpellsController.Instance.GarbageSpellPanelWindows(this.SpellList);

                        this.CompileConditionChanged?.Invoke(this, new EventArgs());
                    }

                    if (this.isZoneChanged)
                    {
                        // インスタンススペルを消去する
                        SpellTable.Instance.RemoveInstanceSpellsAll();

                        // 設定を保存する
                        PluginCore.Instance?.SaveSettingsAsync();

                        var zone   = ActGlobals.oFormActMain.CurrentZone;
                        var zoneID = XIVPluginHelper.Instance?.GetCurrentZoneID();
                        Logger.Write($"zone changed. zone={zone}, zone_id={zoneID}");
                        this.ZoneChanged?.Invoke(this, new EventArgs());

                        Task.Run(() =>
                        {
                            Thread.Sleep(TimeSpan.FromSeconds(6));

                            // 自分の座標をダンプする
                            LogBuffer.DumpPosition(true);

                            // ETを出力する
                            var nowET = EorzeaTime.Now;
                            LogParser.RaiseLog(
                                DateTime.Now,
                                $"[EX] ZoneChanged ET{nowET.Hour:00}:00 Zone:{zoneID:000} {zone}");
                        });
                    }

                    // 定期的に自分の座標をダンプする
                    if ((DateTime.Now - this.lastDumpPositionTimestamp).TotalSeconds >= 60.0)
                    {
                        this.lastDumpPositionTimestamp = DateTime.Now;
                        LogBuffer.DumpPosition(true);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Write("table compiler error:", ex);
            }
            finally
            {
                this.isPartyChanged = false;
                this.isZoneChanged  = false;
            }
        }