public BuffData Copy()
 {
     BuffData ret = new BuffData();
     ret.StartTime = this.StartTime;
     ret.TotalTime = this.TotalTime;
     ret.Changed = this.Changed;
     return ret;
 }
        void oFormActMain_OnCombatEnd(bool isImport, CombatToggleEventArgs encounterInfo)
        {
            lock (locker)
            {
                lastCombatEnd = encounterInfo.encounter.EndTime;

                if (allies != null && allies.Count > 0)
                {
                    List<CombatantData> localAllies = new List<CombatantData>(allies.Count);
                    foreach (var name in allies)
                    {
                        var combatant = encounterInfo.encounter.GetCombatant(name);
                        if (combatant != null)
                        {
                            localAllies.Add(encounterInfo.encounter.GetCombatant(name));
                        }
                    }

                    encounterInfo.encounter.SetAllies(localAllies);
                }

                string charName = ConvertCharName(SecretLanguage.You);
                if (encounterInfo.encounter.GetCombatant(charName) != null)
                {
                    string bossName = encounterInfo.encounter.GetStrongestEnemy(null);
                    if (bossName.IndexOf("_self_") > 0) return; // Prevent _self_-encounters due to dot after fights
                    encounterInfo.encounter.Title = bossName;
                }
                else
                {
                    return;
                }

                Dictionary<string, BuffData> buffDataCopy = new Dictionary<string, BuffData>();
                foreach (var buff in buffData)
                {
                    if (buff.Value.Changed)
                    {
                        BuffData copy = buff.Value.Copy();
                        copy.Stop(encounterInfo.encounter.EndTime);
                        if (copy.TotalTime > encounterInfo.encounter.Duration.TotalMilliseconds)
                        {
                            copy = new BuffData();
                            copy.Start(encounterInfo.encounter.StartTime);
                            copy.Stop(encounterInfo.encounter.EndTime);
                        }

                        buffDataCopy.Add(buff.Key, copy);
                    }
                }

                encounterInfo.encounter.Tags[BUFFS] = buffDataCopy;
            }

            if (checkBox_DontExportShortEnc.Checked && encounterInfo.encounter.Duration.TotalSeconds < 5)
            {
                return;
            }

            CultureInfo usCulture = new CultureInfo("en-US");
            Dictionary<string, Dictionary<string, string>> lines = new Dictionary<string, Dictionary<string, string>>();
            Dictionary<string, Dictionary<string, Dictionary<string, string>>> embedLines = new Dictionary<string, Dictionary<string, Dictionary<string, string>>>();
            SortedDictionary<string, string> displayOrder = new SortedDictionary<string, string>();
            SortedDictionary<string, string> displayOrderHealers = new SortedDictionary<string, string>();
            SortedDictionary<string, string> displayOrderTanks = new SortedDictionary<string, string>();
            SortedDictionary<string, SortedDictionary<string, string>> embedDisplayOrder = new SortedDictionary<string, SortedDictionary<string, string>>();
            if (checkBox_ExportHtml.Checked || checkBox_ExportScript.Checked)
            {
                BuildScriptOutput(encounterInfo.encounter, usCulture, lines, embedLines, displayOrder, embedDisplayOrder, displayOrderHealers, displayOrderTanks);

                if (checkBox_ExportHtml.Checked)
                {
                    GenerateHtmlScript(encounterInfo.encounter, usCulture, lines, embedLines, displayOrder, embedDisplayOrder);
                }

                if (checkBox_ExportScript.Checked)
                {
                    GenerateChatScript(encounterInfo.encounter, usCulture, lines, displayOrder, displayOrderHealers, displayOrderTanks, isImport);
                }
            }
        }