Exemplo n.º 1
0
        public void FillListView()
        {
            lstSpellCasts.Items.Clear();
            if (chkShowUnique.Checked)
            {
                if (Data.castsList.Count > MAX_LIST_VIEW_ITEMS)
                {
                    lstSpellCasts.ListViewItemSorter = null;
                }
                else
                {
                    lstSpellCasts.ListViewItemSorter = listSorter;
                }

                foreach (SpellCastData castDetails in Data.castsList)
                {
                    ListViewItem lvi = new ListViewItem();
                    lvi.Text = castDetails.casterId.ToString();;
                    lvi.SubItems.Add(castDetails.casterType);
                    lvi.SubItems.Add(castDetails.spellId.ToString());
                    lvi.SubItems.Add(castDetails.castFlags.ToString());
                    lvi.SubItems.Add(castDetails.castFlagsEx.ToString());
                    lvi.SubItems.Add(castDetails.targetId.ToString());
                    lvi.SubItems.Add(castDetails.targetType);

                    string           cooldown = "";
                    SpellCooldownKey cdKey    = new SpellCooldownKey(castDetails.casterId, castDetails.casterType, castDetails.spellId);
                    if (Data.spellCooldownsMap.ContainsKey(cdKey))
                    {
                        cooldown = Data.spellCooldownsMap[cdKey].cooldownMin.ToString() + " - " + Data.spellCooldownsMap[cdKey].cooldownMax.ToString();
                    }
                    lvi.SubItems.Add(cooldown);

                    lstSpellCasts.Items.Add(lvi);
                }
            }
            else
            {
                if (Frm_ReadInfo.objectDataTable.Rows.Count > MAX_LIST_VIEW_ITEMS)
                {
                    lstSpellCasts.ListViewItemSorter = null;
                }
                else
                {
                    lstSpellCasts.ListViewItemSorter = listSorter;
                }

                foreach (DataRow rowDetails in Frm_ReadInfo.objectDataTable.Rows)
                {
                    string rowObjectID    = rowDetails["ObjectID"].ToString();
                    string rowObjectType  = rowDetails["ObjectType"].ToString();
                    string rowSpellID     = rowDetails["SpellID"].ToString();
                    string rowCastFlags   = rowDetails["CastFlags"].ToString();
                    string rowCastFlagsEx = rowDetails["CastFlagsEx"].ToString();
                    string rowTargetId    = rowDetails["CasterTarget"].ToString();
                    string rowTargetType  = rowDetails["CasterTargetID"].ToString();
                    string rowTime        = rowDetails["Time"].ToString();

                    ListViewItem lvi = new ListViewItem();
                    lvi.Text = rowObjectID;
                    lvi.SubItems.Add(rowObjectType);
                    lvi.SubItems.Add(rowSpellID);
                    lvi.SubItems.Add(rowCastFlags);
                    lvi.SubItems.Add(rowCastFlagsEx);
                    lvi.SubItems.Add(rowTargetId);
                    lvi.SubItems.Add(rowTargetType);
                    lvi.SubItems.Add(rowTime);
                    lstSpellCasts.Items.Add(lvi);
                }
            }
        }
Exemplo n.º 2
0
        public static void ParseData()
        {
            // Remove any old data.
            spellCooldownsMap.Clear();
            castsList.Clear();
            castTimesList.Clear();

            foreach (DataRow rowData in Frm_ReadInfo.objectDataTable.Rows)
            {
                bool   found               = false;
                UInt32 rowObjectID         = 0;
                string rowObjectType       = rowData["ObjectType"].ToString();
                UInt32 rowSpellID          = 0;
                UInt32 rowCastFlags        = 0;
                UInt32 rowCastFlagsEx      = 0;
                string rowCasterTargetType = rowData["CasterTargetID"].ToString();
                UInt32 rowCasterTargetID   = 0;
                string rowTime             = rowData["Time"].ToString();
                string rowCasterGuid       = rowData["CasterGUID"].ToString();

                UInt32.TryParse(rowData["ObjectID"].ToString(), out rowObjectID);
                UInt32.TryParse(rowData["SpellID"].ToString(), out rowSpellID);
                UInt32.TryParse(rowData["CastFlags"].ToString(), out rowCastFlags);
                UInt32.TryParse(rowData["CastFlagsEx"].ToString(), out rowCastFlagsEx);
                UInt32.TryParse(rowData["CasterTarget"].ToString(), out rowCasterTargetID);

                // Record time of all casts.
                SpellCastTimes castTimeData;
                castTimeData.casterId   = rowObjectID;
                castTimeData.casterType = rowObjectType;
                castTimeData.casterGuid = rowCasterGuid;
                castTimeData.spellId    = rowSpellID;
                castTimeData.castTime   = DateTime.ParseExact(rowTime, "HH:mm:ss", CultureInfo.InvariantCulture);
                castTimesList.Add(castTimeData);

                SpellCooldownKey cdKey = new SpellCooldownKey(rowObjectID, rowObjectType, rowSpellID);
                // Make sure the cooldown dictionary contains all the spell ids.
                if (!spellCooldownsMap.ContainsKey(cdKey))
                {
                    SpellCooldownData tmpCooldownData;
                    tmpCooldownData.cooldownMin = UInt32.MaxValue;
                    tmpCooldownData.cooldownMax = UInt32.MinValue;
                    spellCooldownsMap.Add(cdKey, tmpCooldownData);
                }

                // Skip cast data we already have.
                foreach (SpellCastData listData in castsList)
                {
                    if (listData.casterId == rowObjectID &&
                        listData.casterType == rowObjectType &&
                        listData.spellId == rowSpellID &&
                        listData.castFlags == rowCastFlags &&
                        listData.castFlagsEx == rowCastFlagsEx &&
                        ((listData.targetId == rowCasterTargetID && listData.targetType == rowCasterTargetType) || (listData.targetType.Contains("Player") && rowCasterTargetType.Contains("Player"))))
                    {
                        Console.WriteLine("skip");
                        found = true;
                        break;
                    }
                }

                if (found == true)
                {
                    continue;
                }

                // This cast contains unique data that we want to know about.
                SpellCastData uniqueCastData;
                uniqueCastData.casterId    = rowObjectID;
                uniqueCastData.casterType  = rowObjectType;
                uniqueCastData.spellId     = rowSpellID;
                uniqueCastData.castFlags   = rowCastFlags;
                uniqueCastData.castFlagsEx = rowCastFlagsEx;
                uniqueCastData.targetId    = rowCasterTargetID;
                uniqueCastData.targetType  = rowCasterTargetType;
                castsList.Add(uniqueCastData);
            }

            // Iterate all the casts and calculate cooldowns.
            for (int i = 0; i < castTimesList.Count; i++)
            {
                SpellCastTimes currentCast = castTimesList[i];
                for (int j = i + 1; j < castTimesList.Count; j++)
                {
                    SpellCastTimes nextCast = castTimesList[j];
                    if (nextCast.casterGuid == currentCast.casterGuid &&
                        nextCast.spellId == currentCast.spellId)
                    {
                        SpellCooldownKey  cdKey            = new SpellCooldownKey(currentCast.casterId, currentCast.casterType, currentCast.spellId);
                        System.TimeSpan   diff             = nextCast.castTime.Subtract(currentCast.castTime);
                        SpellCooldownData tempCooldownData = spellCooldownsMap[cdKey];
                        if (tempCooldownData.cooldownMin > diff.TotalSeconds)
                        {
                            tempCooldownData.cooldownMin = (UInt32)diff.TotalSeconds;
                        }
                        if ((tempCooldownData.cooldownMax < diff.TotalSeconds) &&
                            !((tempCooldownData.cooldownMax > 0) && (diff.TotalSeconds > tempCooldownData.cooldownMax * 10))) // ignore if new max cooldown is absurdly bigger than last one, it could be that creature evaded and was engaged again later
                        {
                            tempCooldownData.cooldownMax = (UInt32)diff.TotalSeconds;
                        }
                        spellCooldownsMap[cdKey] = tempCooldownData;
                        break;
                    }
                }
            }

            // Remove rows from spell cooldowns table if the cast was seen only once, and thus cooldown data has default values.
            foreach (var item in spellCooldownsMap.Where(kvp => kvp.Value.cooldownMin == UInt32.MaxValue).ToList())
            {
                spellCooldownsMap.Remove(item.Key);
            }
        }