コード例 #1
0
        public void ProcessItem(IdentResponse item)
        {
            TotalSpells += item.Spells.Count;

            if (item.Spells.Count < MinSpells)
            {
                MinSpells = item.Spells.Count;
            }
            if (item.Spells.Count > MaxSpells)
            {
                MaxSpells = item.Spells.Count;
            }

            foreach (var id in item.Spells)
            {
                var spell = SpellTools.GetSpell(id);

                HitsByBuffLevels.TryGetValue(spell.BuffLevel, out var count1);
                count1++;
                HitsByBuffLevels[spell.BuffLevel] = count1;

                HitsByCantrip.TryGetValue(spell.CantripLevel, out var count2);
                count2++;
                HitsByCantrip[spell.CantripLevel] = count2;

                HitsBySpellID.TryGetValue(id, out var count3);
                count3++;
                HitsBySpellID[id] = count3;
            }
        }
コード例 #2
0
        public void ProcessItem(IdentResponse item)
        {
            TotalItems++;

            if (item.LongValues.ContainsKey(IntValueKey.Workmanship))
            {
                if (!WorkmanshipHits.ContainsKey(item.LongValues[IntValueKey.Workmanship]))
                {
                    WorkmanshipHits[item.LongValues[IntValueKey.Workmanship]] = 0;
                }

                WorkmanshipHits[item.LongValues[IntValueKey.Workmanship]]++;
            }

            if (item.LongValues.ContainsKey(IntValueKey.Material))
            {
                if (!MaterialHits.ContainsKey((MaterialType)item.LongValues[IntValueKey.Material]))
                {
                    MaterialHits[(MaterialType)item.LongValues[IntValueKey.Material]] = 0;
                }

                MaterialHits[(MaterialType)item.LongValues[IntValueKey.Material]]++;
            }

            if (item.LongValues.ContainsKey(IntValueKey.Workmanship))
            {
                SpellStats.ProcessItem(item);
            }

            ObjectClasses[item.ObjectClass].ProcessItem(item);
        }
コード例 #3
0
ファイル: SpellStats.cs プロジェクト: TooGoooD1/Mag-Plugins
        public void ProcessItem(IdentResponse item)
        {
            TotalItems++;
            TotalSpells += item.Spells.Count;

            if (item.Spells.Count < MinSpells)
            {
                MinSpells = item.Spells.Count;
            }
            if (item.Spells.Count > MaxSpells)
            {
                MaxSpells = item.Spells.Count;
            }

            var cantripCount = 0;
            var buffCount    = 0;

            foreach (var id in item.Spells)
            {
                var spell = SpellTools.GetSpell(id);

                if (spell.BuffLevel != Spell.BuffLevels.None)
                {
                    HitsByBuffLevels.TryGetValue(spell.BuffLevel, out var count1);
                    count1++;
                    HitsByBuffLevels[spell.BuffLevel] = count1;

                    buffCount++;
                }

                if (spell.CantripLevel != Spell.CantripLevels.None)
                {
                    HitsByCantrip.TryGetValue(spell.CantripLevel, out var count2);
                    count2++;
                    HitsByCantrip[spell.CantripLevel] = count2;

                    cantripCount++;
                }

                HitsBySpellID.TryGetValue(id, out var count3);
                count3++;
                HitsBySpellID[id] = count3;
            }

            if (!BuffLevelCountHits.ContainsKey(buffCount))
            {
                BuffLevelCountHits.Add(buffCount, 0);
            }
            BuffLevelCountHits[buffCount]++;

            if (!CantripCountHits.ContainsKey(cantripCount))
            {
                CantripCountHits.Add(cantripCount, 0);
            }
            CantripCountHits[cantripCount]++;
        }
コード例 #4
0
        // todo
        // Food
        // Money
        // Misc
        // Gem
        // SpellComponent
        // Key
        // ManaStone
        // Healing Kit
        // Lockpick
        // Scroll


        public void ProcessItem(IdentResponse item)
        {
            if (item.ObjectClass == ObjectClass.MeleeWeapon)
            {
                MeleeWeapons.ProcessItem(item);
            }
            else if (item.ObjectClass == ObjectClass.MissileWeapon)
            {
                MissileWeapons.ProcessItem(item);
            }
            else if (item.ObjectClass == ObjectClass.WandStaffOrb)
            {
                WandStaffOrbs.ProcessItem(item);
            }
            else
            {
                ; // catch here to see if we're not processing an object class
            }
        }
コード例 #5
0
ファイル: Form1.cs プロジェクト: warweaver/Mag-Plugins
        private bool ProcessLootItem(string containerName, int containerID, IdentResponse identResponse)
        {
            lock (processLockObject)
            {
                Dictionary <int, List <IdentResponse> > containers;

                if (containersLoot.ContainsKey(containerName))
                {
                    containers = containersLoot[containerName];
                }
                else
                {
                    containers = new Dictionary <int, List <IdentResponse> >();
                    containersLoot.Add(containerName, containers);
                }

                List <IdentResponse> items;

                if (containers.ContainsKey(containerID))
                {
                    items = containers[containerID];
                }
                else
                {
                    items = new List <IdentResponse>();
                    containers.Add(containerID, items);
                }

                // Does this item already exist?
                foreach (var item in items)
                {
                    if (item.Id == identResponse.Id)
                    {
                        return(true);
                    }
                }

                items.Add(identResponse);

                return(true);
            }
        }
コード例 #6
0
        private void ProcessLootItem(uint containerID, string containerName, int landcell, string location, IdentResponse identResponse)
        {
            // Player Corpses
            if (containerName == "Corpse of Father Of Sin" ||
                containerName == "Corpse of Copastetic" ||
                containerName == "Corpse of Blumenkind" ||
                containerName == "Corpse of Cyberkiller" ||
                containerName == "Corpse of Sholdslastridelc" ||
                containerName == "Corpse of Thisistheendmyonlyfriendtheend")
            {
                Interlocked.Increment(ref skippedLines);
                return;
            }

            // Housing containers can contain anything
            if (containerName == "Chest")
            {
                Interlocked.Increment(ref skippedLines);
                return;
            }

            // These landscape containers seem to be multi-tier
            if (containerName == "Runed Chest" ||
                containerName == "Coral Encrusted Chest")
            {
                Interlocked.Increment(ref skippedLines);
                return;
            }

            // These items are odd-balls that were found in corpses. Possibly code error, or maybe a player put the item in the corpse?
            // Corpse of Grave Rat
            if (identResponse.Id == 0xDD2B79A9 && identResponse.StringValues[Mag.Shared.Constants.StringValueKey.Name] == "Electric Spine Glaive")
            {
                Interlocked.Increment(ref skippedLines);
                return;
            }
            // Corpse of Drudge Slave
            if (identResponse.Id == 0xDC94F88A && identResponse.StringValues[Mag.Shared.Constants.StringValueKey.Name] == "Heavy Crossbow")
            {
                Interlocked.Increment(ref skippedLines);
                return;
            }
            if (identResponse.Id == 0xDC9AE6E2 && identResponse.StringValues[Mag.Shared.Constants.StringValueKey.Name] == "Katar")
            {
                Interlocked.Increment(ref skippedLines);
                return;
            }
            // Corpse of Mercenary
            if (identResponse.Id == 0xABCC0A35 && identResponse.StringValues[Mag.Shared.Constants.StringValueKey.Name] == "Studded Leather Breastplate")
            {
                Interlocked.Increment(ref skippedLines);
                return;
            }

            // Not sure why corpses are being detected as inside a container, probably a data bug
            if (identResponse.ObjectClass == Mag.Shared.ObjectClass.Corpse)
            {
                Interlocked.Increment(ref skippedLines);
                return;
            }

            lock (processLockObject)
            {
                List <ContainerInfo> containers;

                if (containersLoot.ContainsKey(containerName))
                {
                    containers = containersLoot[containerName];
                }
                else
                {
                    containers = new List <ContainerInfo>();
                    containersLoot.Add(containerName, containers);
                }

                ContainerInfo containerInfo = null;

                foreach (var container in containers)
                {
                    if (container.Id == containerID && container.Name == containerName && container.Landcell == landcell && container.Location == location)
                    {
                        containerInfo = container;
                        break;
                    }
                }

                if (containerInfo == null)
                {
                    containerInfo = new ContainerInfo {
                        Id = containerID, Name = containerName, Landcell = landcell, Location = location
                    };
                    containers.Add(containerInfo);
                }

                // Does this item already exist?
                foreach (var item in containerInfo.Items)
                {
                    if (item.Id == identResponse.Id)
                    {
                        return;
                    }
                }

                containerInfo.Items.Add(identResponse);

                return;
            }
        }
コード例 #7
0
        private void ProcessFile(string fileName, CancellationToken ct)
        {
            var fileLines = File.ReadAllLines(fileName);

            // "Timestamp","ContainerName","ContainerID","LandCell","Location","JSON"
            if (fileLines.Length < 2 || fileLines[0] != "\"Timestamp\",\"ContainerName\",\"ContainerID\",\"LandCell\",\"Location\",\"JSON\"")
            {
                return;
            }

            lock (totalLinesLockObject)
                totalLines += fileLines.Length;

            for (int i = 0; i < fileLines.Length; i++)
            {
                if (ct.IsCancellationRequested)
                {
                    return;
                }

                // "2017-01-20 08:18:48Z,"Monty's Golden Chest",2056986702,"A9B20117","40.8N, 33.6E","{"Id":"-1419165865","ObjectClass":"Misc","BoolValues":{"69":"True"},"DoubleValues":{"167":"45","167772170":"0"},"LongValues":{"367":"430","375":"7","218103835":"67108882","218103843":"8","280":"213","33":"0","105":"7","369":"115","114":"0","366":"54","374":"13","218103810":"2056986634","218103826":"16","218103830":"33554817","218103834":"128","218103850":"29728","19":"7000","91":"50","218103831":"48","218103847":"137345","92":"50","218103808":"49548","218103824":"64","218103832":"1076382872","5":"50","218103809":"4154","218103833":"7","218103849":"29733"},"StringValues":{"1":"Lightning Phyntos Wasp Essence (125)","14":"Use this essence to summon or dismiss your Lightning Phyntos Wasp."},"ActiveSpells":"","Spells":""}"
                // "2017-01-20 08:18:48Z,"Monty's Golden Chest",2056986702,"A9B20117","40.8N, 33.6E","{"Id":"-1419511451","ObjectClass":"Scroll","BoolValues":{},"DoubleValues":{"167772170":"0"},"LongValues":{"19":"2000","218103831":"16","218103835":"18","218103843":"8","218103847":"135297","218103808":"45258","218103816":"5785","218103832":"6307864","218103848":"0","5":"30","218103809":"28959","218103810":"2056986634","218103830":"33554826","218103834":"8192","218103838":"1"},"StringValues":{"1":"Scroll of Dirty Fighting Mastery Self VII","14":"Use this item to attempt to learn its spell.","16":"Inscribed spell: Dirty Fighting Mastery Self VII Increases the caster's Dirty Fighting skill by 40 points."},"ActiveSpells":"","Spells":"5785"}"
                // "2017-01-15 04:02:33Z,"Corpse of Mu-miyah Sentinel",-1851166334,"8764003C","21.6S, 6.8E","{"Id":"-1851166529","ObjectClass":"Money","BoolValues":{},"DoubleValues":{},"LongValues":{"19":"4775","218103815":"25000","218103831":"1","218103835":"16","218103843":"1","218103847":"131073","218103808":"273","218103832":"28696","5":"0","218103809":"8863","218103810":"-1851166402","218103814":"4775","218103830":"33557367","218103834":"64"},"StringValues":{"1":"Pyreal"},"ActiveSpells":"","Spells":""}"

                try
                {
                    var line = fileLines[i];

                    // "2017-01-19 09:03:44Z,"Corpse of Gigas Raider",-1419920476,"02E70109","81.3N, 99.2W","{"Id":"-1419521241","ObjectClass":"Scroll","BoolValues":{},"DoubleValues":{"167772170":"0"},"LongValues":{"19":"100","218103831":"16","218103835":"18","218103843":"8","218103847":"135297","218103808":"3060","218103816":"1087","218103832":"6307864","218103848":"0","5":"30","218103809":"13652","218103810":"-1419920544","218103830":"33554826","218103834":"8192","218103838":"1"},"StringValues":{"1":"Scroll of Lightning Vulnerability Other IV","14":"Use this item to attempt to learn its spell.","16":"Inscribed spell: Lightning Vulnerability Other IV
                    // Increases damage the target takes from Lightning by 75%."},"ActiveSpells":"","Spells":"1087"}"
                    if (i < fileLines.Length - 1)
                    {
                        var nextLine = fileLines[i + 1];

                        var thisLineIsTerminated   = line.EndsWith("}\"");
                        var nextLineHasProperStart = nextLine.StartsWith("\"") && !nextLine.StartsWith("\",");

                        if (!thisLineIsTerminated && !nextLineHasProperStart)
                        {
                            line += '\n' + nextLine;
                            i++;

                            // "2017-01-31 11:39:31Z,"Corpse of Cyberkiller",-583852276,"C4A80102","32.6N, 55.0E","{"Id":"-583994245","ObjectClass":"Armor","BoolValues":{"100":"True"},"DoubleValues":{"167772160":"1.29999995231628","167772164":"0.341241389513016","167772161":"1","167772163":"0.600000023841858","167772165":"0.400000005960464","167772169":"3","5":"-0.0333333350718021","167772162":"1","167772166":"0.400000005960464"},"LongValues":{"218103835":"18","218103843":"1","105":"3","218103821":"15360","106":"194","110":"0","218103810":"-583852344","218103822":"7680","218103830":"33554644","218103834":"2","218103838":"3","19":"13665","107":"123","115":"0","131":"60","218103831":"16","218103847":"137217","28":"146","108":"441","218103808":"72","218103824":"1","218103832":"-2128265064","218103848":"0","5":"4126","109":"194","218103809":"6300"},"StringValues":{"1":"Platemail Hauberk","7":"AL 146
                            // Imp III, Acid Bane II, Frost Bane IV
                            // 1/29, Diff 194","8":"Shai'tan","16":"Finely crafted Gold Platemail Hauberk , set with 4 Peridots"},"ActiveSpells":"","Spells":"1483,1494,1526"}"
                            if (i < fileLines.Length - 1)
                            {
                                nextLine = fileLines[i + 1];

                                thisLineIsTerminated   = line.EndsWith("}\"");
                                nextLineHasProperStart = nextLine.StartsWith("\"");

                                if (!thisLineIsTerminated && !nextLineHasProperStart)
                                {
                                    line += '\n' + nextLine;
                                    i++;
                                }
                            }
                        }
                    }

                    var sixthComma = Util.IndexOfNth(line, ',', 6);

                    if (sixthComma == -1) // Corrupt line
                    {
                        if (line != "\"Timestamp\",\"ContainerName\",\"ContainerID\",\"LandCell\",\"Location\",\"JSON\"")
                        {
                            Interlocked.Increment(ref corruptLines);
                        }
                        continue;
                    }

                    var firstPart = line.Substring(0, sixthComma);

                    var firstPartSplit = firstPart.Split(',');
                    if (firstPartSplit[0] == "\"Timestamp\"") // Header line
                    {
                        continue;
                    }

                    if (!DateTime.TryParse(firstPartSplit[0].Substring(1, firstPartSplit[0].Length - 2), out var timestamp)) // Corrupt line
                    {
                        Interlocked.Increment(ref corruptLines);
                        continue;
                    }

                    var containerName = firstPartSplit[1].Substring(1, firstPartSplit[1].Length - 2);

                    var containerID = (uint)int.Parse(firstPartSplit[2].Substring(2, firstPartSplit[2].Length - 2));

                    if (!int.TryParse(firstPartSplit[3].Substring(1, firstPartSplit[3].Length - 2), NumberStyles.HexNumber, null, out var landcell)) // Corrupt line
                    {
                        Interlocked.Increment(ref corruptLines);
                        continue;
                    }

                    var location = firstPartSplit[4].Substring(1) + ", " + firstPartSplit[5].Substring(0, firstPartSplit[5].Length - 1);

                    var jsonPart = line.Substring(sixthComma + 1, line.Length - (sixthComma + 1));
                    if (jsonPart[0] != '"' || jsonPart[jsonPart.Length - 1] != '"') // Corrupt line
                    {
                        Interlocked.Increment(ref corruptLines);
                        continue;
                    }

                    jsonPart = jsonPart.Substring(1, jsonPart.Length - 2); // Trim the quotes... why did I add them.. :(

                    if (jsonPart.StartsWith("{\"Id"))
                    {
                        // Fix json errors
                        jsonPart = jsonPart.Replace("\"Enchanted\"", "\\\"Enchanted\\\"");
                        jsonPart = jsonPart.Replace("\"Bunny Master\"", "\\\"Bunny Master\\\"");
                        jsonPart = jsonPart.Replace("\"Samuel\"", "\\\"Samuel\\\"");

                        jsonPart = jsonPart.Replace("\"Is that what I think it is?\"", "\\\"Is that what I think it is?\\\"");

                        jsonPart = jsonPart.Replace("\"Procedures By", "\\\"Procedures By");
                        jsonPart = jsonPart.Replace("The Creeping Blight.\"", "The Creeping Blight.\\\"");

                        var identResponse = new IdentResponse();

                        identResponse.Timestamp = timestamp;
                        identResponse.Landcell  = landcell;
                        //identResponse.RawCoordinates = rawCoordinates;

                        Dictionary <string, object> result = (Dictionary <string, object>)jsonSerializer.DeserializeObject(jsonPart);

                        identResponse.ParseFromDictionary(result);

                        if (ct.IsCancellationRequested)
                        {
                            return;
                        }

                        ProcessLootItem(containerID, containerName, landcell, location, identResponse);
                    }
                    else
                    {
                        Interlocked.Increment(ref corruptLines);
                        continue;
                    }
                }
                catch // Item is likely inscribed
                {
                    Interlocked.Increment(ref corruptLines);
                    continue;
                }
            }
        }
コード例 #8
0
ファイル: Form1.cs プロジェクト: Mag-nus/Mag-Plugins
        private void ProcessLootItemNoChecks(uint containerID, string containerName, int landcell, string location, IdentResponse identResponse)
        {
            lock (processLockObject)
            {
                List <ContainerInfo> containers;

                if (containersLoot.ContainsKey(containerName))
                {
                    containers = containersLoot[containerName];
                }
                else
                {
                    containers = new List <ContainerInfo>();
                    containersLoot.Add(containerName, containers);
                }

                ContainerInfo containerInfo = null;

                foreach (var container in containers)
                {
                    if (container.Id == containerID && container.Name == containerName && container.Landcell == landcell && container.Location == location)
                    {
                        containerInfo = container;
                        break;
                    }
                }

                if (containerInfo == null)
                {
                    containerInfo = new ContainerInfo {
                        Id = containerID, Name = containerName, Landcell = landcell, Location = location
                    };
                    containers.Add(containerInfo);
                }

                // Does this item already exist?
                foreach (var item in containerInfo.Items)
                {
                    if (item.Id == identResponse.Id)
                    {
                        return;
                    }
                }

                containerInfo.Items.Add(identResponse);
            }
        }
コード例 #9
0
ファイル: Form1.cs プロジェクト: Mag-nus/Mag-Plugins
        private void ProcessLootItemWithChecks(uint containerID, string containerName, int landcell, string location, IdentResponse identResponse)
        {
            // Player Corpses
            if (containerName == "Corpse of Father Of Sin" ||
                containerName == "Corpse of Copastetic" ||
                containerName == "Corpse of Blumenkind" ||
                containerName == "Corpse of Cyberkiller" ||
                containerName == "Corpse of Sholdslastridelc" ||
                containerName == "Corpse of Thisistheendmyonlyfriendtheend" ||
                containerName == "Corpse of Dieter the Black" ||
                containerName == "Corpse of Twangs" ||
                containerName == "Corpse of Big D Boy" ||
                containerName == "Corpse of Blood Quench" ||
                containerName == "Corpse of Ripley of Frostfell" ||
                containerName == "Corpse of Al Bow" ||
                containerName == "Corpse of Ashly g" ||
                containerName == "Corpse of Zojak Quazith" ||
                containerName == "Corpse of Crimson Mage of Mt" ||
                containerName == "Corpse of Mr Goodman's Goodies" ||
                containerName == "Corpse of Mag-nus" ||
                containerName == "Corpse of Dirty Mike" ||
                containerName == "Corpse of Shootey McWarwand" ||
                containerName == "Corpse of Sinner of Dt" ||
                containerName == "Corpse of Rimok" ||
                containerName == "Corpse of Ujiio")

            {
                Interlocked.Increment(ref skippedLines);
                return;
            }

            // Housing containers can contain anything
            if (containerName == "Chest")
            {
                Interlocked.Increment(ref skippedLines);
                return;
            }

            // These landscape containers seem to be multi-tier
            if (containerName == "Runed Chest" ||
                containerName == "Coral Encrusted Chest")
            {
                Interlocked.Increment(ref skippedLines);
                return;
            }

            // These items are odd-balls that were found in corpses. Possibly code error, or maybe a player put the item in the corpse?
            // Corpse of Grave Rat
            if (identResponse.Id == 0xDD2B79A9 && identResponse.StringValues[StringValueKey.Name] == "Electric Spine Glaive")
            {
                Interlocked.Increment(ref skippedLines);
                return;
            }
            // Corpse of Drudge Slave
            if (identResponse.Id == 0xDC94F88A && identResponse.StringValues[StringValueKey.Name] == "Heavy Crossbow")
            {
                Interlocked.Increment(ref skippedLines);
                return;
            }
            if (identResponse.Id == 0xDC9AE6E2 && identResponse.StringValues[StringValueKey.Name] == "Katar")
            {
                Interlocked.Increment(ref skippedLines);
                return;
            }
            if (identResponse.Id == 0xD80AB491 && identResponse.StringValues[StringValueKey.Name] == "Flaming Great Star Mace")
            {
                Interlocked.Increment(ref skippedLines);
                return;
            }
            // Corpse of Mercenary
            if (identResponse.Id == 0xABCC0A35 && identResponse.StringValues[StringValueKey.Name] == "Studded Leather Breastplate")
            {
                Interlocked.Increment(ref skippedLines);
                return;
            }
            // Corpse of Mahharu
            if (identResponse.Id == 0xAAFFFDEB && identResponse.StringValues[StringValueKey.Name] == "War Axe")
            {
                Interlocked.Increment(ref skippedLines);
                return;
            }

            // Not sure why corpses are being detected as inside a container, probably a data bug
            if (identResponse.ObjectClass == Mag.Shared.ObjectClass.Corpse)
            {
                Interlocked.Increment(ref skippedLines);
                return;
            }

            ProcessLootItemNoChecks(containerID, containerName, landcell, location, identResponse);
        }
コード例 #10
0
ファイル: Form1.cs プロジェクト: warweaver/Mag-Plugins
        private void ProcessFile(string fileName, CancellationToken ct)
        {
            var fileLines = File.ReadAllLines(fileName);

            // "Timestamp","ContainerName","ContainerID","LandCell","Location","JSON"
            if (fileLines.Length < 2 || fileLines[0] != "\"Timestamp\",\"ContainerName\",\"ContainerID\",\"LandCell\",\"Location\",\"JSON\"")
            {
                return;
            }

            lock (totalLinesLockObject)
                totalLines += fileLines.Length;

            foreach (var line in fileLines)
            {
                if (ct.IsCancellationRequested)
                {
                    return;
                }

                // "2017-01-20 08:18:48Z,"Monty's Golden Chest",2056986702,"A9B20117","40.8N, 33.6E","{"Id":"-1419165865","ObjectClass":"Misc","BoolValues":{"69":"True"},"DoubleValues":{"167":"45","167772170":"0"},"LongValues":{"367":"430","375":"7","218103835":"67108882","218103843":"8","280":"213","33":"0","105":"7","369":"115","114":"0","366":"54","374":"13","218103810":"2056986634","218103826":"16","218103830":"33554817","218103834":"128","218103850":"29728","19":"7000","91":"50","218103831":"48","218103847":"137345","92":"50","218103808":"49548","218103824":"64","218103832":"1076382872","5":"50","218103809":"4154","218103833":"7","218103849":"29733"},"StringValues":{"1":"Lightning Phyntos Wasp Essence (125)","14":"Use this essence to summon or dismiss your Lightning Phyntos Wasp."},"ActiveSpells":"","Spells":""}"
                // "2017-01-20 08:18:48Z,"Monty's Golden Chest",2056986702,"A9B20117","40.8N, 33.6E","{"Id":"-1419511451","ObjectClass":"Scroll","BoolValues":{},"DoubleValues":{"167772170":"0"},"LongValues":{"19":"2000","218103831":"16","218103835":"18","218103843":"8","218103847":"135297","218103808":"45258","218103816":"5785","218103832":"6307864","218103848":"0","5":"30","218103809":"28959","218103810":"2056986634","218103830":"33554826","218103834":"8192","218103838":"1"},"StringValues":{"1":"Scroll of Dirty Fighting Mastery Self VII","14":"Use this item to attempt to learn its spell.","16":"Inscribed spell: Dirty Fighting Mastery Self VII Increases the caster's Dirty Fighting skill by 40 points."},"ActiveSpells":"","Spells":"5785"}"
                // "2017-01-15 04:02:33Z,"Corpse of Mu-miyah Sentinel",-1851166334,"8764003C","21.6S, 6.8E","{"Id":"-1851166529","ObjectClass":"Money","BoolValues":{},"DoubleValues":{},"LongValues":{"19":"4775","218103815":"25000","218103831":"1","218103835":"16","218103843":"1","218103847":"131073","218103808":"273","218103832":"28696","5":"0","218103809":"8863","218103810":"-1851166402","218103814":"4775","218103830":"33557367","218103834":"64"},"StringValues":{"1":"Pyreal"},"ActiveSpells":"","Spells":""}"

                try
                {
                    var sixthComma = Util.IndexOfNth(line, ',', 6);

                    if (sixthComma == -1) // Corrupt line
                    {
                        Interlocked.Increment(ref corruptLines);
                        continue;
                    }

                    var firstPart = line.Substring(0, sixthComma);

                    var firstPartSplit = firstPart.Split(',');
                    if (firstPartSplit[0] == "\"Timestamp\"") // Header line
                    {
                        continue;
                    }

                    DateTime timestamp;
                    if (!DateTime.TryParse(firstPartSplit[0].Substring(1, firstPartSplit[0].Length - 2), out timestamp)) // Corrupt line
                    {
                        Interlocked.Increment(ref corruptLines);
                        continue;
                    }

                    var containerName = firstPartSplit[1].Substring(1, firstPartSplit[1].Length - 2);

                    var containerID = int.Parse(firstPartSplit[2].Substring(2, firstPartSplit[2].Length - 2));

                    int landcell;
                    if (!int.TryParse(firstPartSplit[3].Substring(1, firstPartSplit[3].Length - 2), NumberStyles.HexNumber, null, out landcell)) // Corrupt line
                    {
                        Interlocked.Increment(ref corruptLines);
                        continue;
                    }

                    var location = firstPartSplit[4].Substring(1) + ", " + firstPartSplit[5].Substring(0, firstPartSplit[5].Length - 1);

                    var jsonPart = line.Substring(sixthComma + 1, line.Length - (sixthComma + 1));
                    if (jsonPart[0] != '"' || jsonPart[jsonPart.Length - 1] != '"') // Corrupt line
                    {
                        Interlocked.Increment(ref corruptLines);
                        continue;
                    }

                    jsonPart = jsonPart.Substring(1, jsonPart.Length - 2); // Trim the quotes... why did I add them.. :(

                    if (jsonPart.StartsWith("{\"Id"))
                    {
                        var identResponse = new IdentResponse();

                        identResponse.Timestamp = timestamp;
                        identResponse.Landcell  = landcell;
                        //identResponse.RawCoordinates = rawCoordinates;

                        Dictionary <string, object> result = (Dictionary <string, object>)jsonSerializer.DeserializeObject(jsonPart);

                        identResponse.ParseFromDictionary(result);

                        if (ct.IsCancellationRequested)
                        {
                            return;
                        }

                        if (!ProcessLootItem(containerName, containerID, identResponse))
                        {
                            Interlocked.Increment(ref corruptLines);
                            continue;
                        }
                    }
                    else
                    {
                        Interlocked.Increment(ref corruptLines);
                        continue;
                    }
                }
                catch
                {
                    Interlocked.Increment(ref corruptLines);
                    continue;
                }
            }
        }
コード例 #11
0
        public void ProcessItem(IdentResponse item)
        {
            TotalItems++;

            SpellStats.ProcessItem(item);
        }