From 364e97a93318ad1a4d83d2ed2d960aed84869014 Mon Sep 17 00:00:00 2001 From: Marrow16180 Date: Mon, 25 Jun 2018 21:02:04 +0200 Subject: [PATCH] Reduce amount of heap allocations by changing List constructors or replacing them by Array --- WowPacketParser/Parsing/Parsers/NpcHandler.cs | 14 ++++----- .../Parsers/Presence.cs | 2 +- .../Parsers/NpcHandler.cs | 28 +++++++++-------- .../Parsers/NpcHandler.cs | 16 +++++----- .../Parsers/NpcHandler.cs | 28 +++++++++-------- .../Parsers/NpcHandler.cs | 28 +++++++++-------- .../Parsers/NpcHandler.cs | 30 ++++++++++--------- .../Parsers/SpellHandler.cs | 1 - .../Parsers/NpcHandler.cs | 30 ++++++++++--------- .../Parsers/PetHandler.cs | 1 - .../Parsers/UpdateHandler.cs | 13 ++++---- 11 files changed, 98 insertions(+), 93 deletions(-) diff --git a/WowPacketParser/Parsing/Parsers/NpcHandler.cs b/WowPacketParser/Parsing/Parsers/NpcHandler.cs index 01c92080f0..39b0d0496a 100644 --- a/WowPacketParser/Parsing/Parsers/NpcHandler.cs +++ b/WowPacketParser/Parsing/Parsers/NpcHandler.cs @@ -276,10 +276,10 @@ public static void HandleVendorInventoryList434(Packet packet) guidBytes[4] = packet.ReadBit(); - var tempList = new List(); + var tempArray = new NpcVendor[count]; for (int i = 0; i < count; ++i) { - NpcVendor npcVendor = new NpcVendor + var npcVendor = new NpcVendor { Slot = packet.ReadInt32("Item Position", i) }; @@ -300,7 +300,7 @@ public static void HandleVendorInventoryList434(Packet packet) if (npcVendor.Type == 2) npcVendor.MaxCount = buyCount; - tempList.Add(npcVendor); + tempArray[i] = npcVendor; } packet.ReadXORByte(guidBytes, 5); @@ -316,11 +316,11 @@ public static void HandleVendorInventoryList434(Packet packet) packet.ReadXORByte(guidBytes, 7); uint entry = packet.WriteGuid("GUID", guidBytes).GetEntry(); - tempList.ForEach(v => + for(int i = 0; i < count; ++i) { - v.Entry = entry; - Storage.NpcVendors.Add(v, packet.TimeSpan); - }); + tempArray[i].Entry = entry; + Storage.NpcVendors.Add(tempArray[i], packet.TimeSpan); + } } [Parser(Opcode.CMSG_GOSSIP_HELLO)] diff --git a/WowPacketParserModule.BattleNet.V37165/Parsers/Presence.cs b/WowPacketParserModule.BattleNet.V37165/Parsers/Presence.cs index 259146d2a7..59a2a307e0 100644 --- a/WowPacketParserModule.BattleNet.V37165/Parsers/Presence.cs +++ b/WowPacketParserModule.BattleNet.V37165/Parsers/Presence.cs @@ -25,7 +25,7 @@ public static void HandleUpdateNotify(BattlenetPacket packet) varSizes.Enqueue(packet.Read(0, 16)); count = packet.Read(0, 4); - var handles = new List(); + var handles = new List(count); for (var i = 0; i < count; ++i) handles.Add(packet.Read(0, 32)); diff --git a/WowPacketParserModule.V5_3_0_16981/Parsers/NpcHandler.cs b/WowPacketParserModule.V5_3_0_16981/Parsers/NpcHandler.cs index a792275fc2..e3eda1ac66 100644 --- a/WowPacketParserModule.V5_3_0_16981/Parsers/NpcHandler.cs +++ b/WowPacketParserModule.V5_3_0_16981/Parsers/NpcHandler.cs @@ -167,7 +167,7 @@ public static void HandleServerTrainerList(Packet packet) packet.StartBitStream(guidBytes, 3, 7, 1, 4, 5); packet.ResetBitReader(); - var tempList = new List(); + var tempArray = new TrainerSpell[count]; for (int i = 0; i < count; ++i) { TrainerSpell trainerSpell = new TrainerSpell @@ -184,7 +184,7 @@ public static void HandleServerTrainerList(Packet packet) trainerSpell.SpellId = packet.ReadUInt32("SpellID", i); packet.ReadByteE("Usable", i); - tempList.Add(trainerSpell); + tempArray[i] = trainerSpell; } Trainer trainer = new Trainer(); @@ -197,11 +197,13 @@ public static void HandleServerTrainerList(Packet packet) packet.WriteGuid("TrainerGUID", guidBytes); Storage.Trainers.Add(trainer, packet.TimeSpan); - tempList.ForEach(trainerSpell => + + for(int i = 0; i < count; ++i) { - trainerSpell.TrainerId = trainer.Id; - Storage.TrainerSpells.Add(trainerSpell, packet.TimeSpan); - }); + tempArray[i].TrainerId = trainer.Id; + Storage.TrainerSpells.Add(tempArray[i], packet.TimeSpan); + } + var lastGossipOption = CoreParsers.NpcHandler.LastGossipOption; if (lastGossipOption.HasSelection) Storage.GossipMenuOptionTrainers.Add(new GossipMenuOptionTrainer { MenuId = lastGossipOption.MenuId, OptionIndex = lastGossipOption.OptionIndex, TrainerId = trainer.Id }, packet.TimeSpan); @@ -230,10 +232,10 @@ public static void HandleVendorInventoryList(Packet packet) packet.ResetBitReader(); packet.ReadXORBytes(guid, 3, 4); - var tempList = new List(); + var tempArray = new NpcVendor[itemCount]; for (int i = 0; i < itemCount; ++i) { - NpcVendor vendor = new NpcVendor + var vendor = new NpcVendor { Item = packet.ReadInt32("Item ID", i), Slot = packet.ReadInt32("Item Position", i) @@ -257,7 +259,7 @@ public static void HandleVendorInventoryList(Packet packet) if (vendor.Type == 2) vendor.MaxCount = buyCount; - tempList.Add(vendor); + tempArray[i] = vendor; } packet.ReadXORBytes(guid, 1, 2, 7); @@ -265,11 +267,11 @@ public static void HandleVendorInventoryList(Packet packet) packet.ReadXORBytes(guid, 6, 0, 5); uint entry = packet.WriteGuid("GUID", guid).GetEntry(); - tempList.ForEach(v => + for(int i = 0; i < itemCount; ++i) { - v.Entry = entry; - Storage.NpcVendors.Add(v, packet.TimeSpan); - }); + tempArray[i].Entry = entry; + Storage.NpcVendors.Add(tempArray[i], packet.TimeSpan); + } } } } diff --git a/WowPacketParserModule.V5_4_0_17359/Parsers/NpcHandler.cs b/WowPacketParserModule.V5_4_0_17359/Parsers/NpcHandler.cs index 9abad7d166..3fa2960f08 100644 --- a/WowPacketParserModule.V5_4_0_17359/Parsers/NpcHandler.cs +++ b/WowPacketParserModule.V5_4_0_17359/Parsers/NpcHandler.cs @@ -282,8 +282,6 @@ public static void HandleThreatlistUpdate(Packet packet) [Parser(Opcode.SMSG_VENDOR_INVENTORY)] public static void HandleVendorInventoryList(Packet packet) { - - var guid = new byte[8]; guid[5] = packet.ReadBit(); @@ -305,10 +303,10 @@ public static void HandleVendorInventoryList(Packet packet) packet.ReadXORByte(guid, 6); packet.ReadXORByte(guid, 1); - var tempList = new List(); + var tempArray = new NpcVendor[count]; for (int i = 0; i < count; ++i) { - NpcVendor vendor = new NpcVendor(); + var vendor = new NpcVendor(); int maxCount = packet.ReadInt32("Max Count", i); vendor.Type = packet.ReadUInt32("Type", i); // 1 - item, 2 - currency @@ -331,7 +329,7 @@ public static void HandleVendorInventoryList(Packet packet) if (vendor.Type == 2) vendor.MaxCount = buyCount; - tempList.Add(vendor); + tempArray[i] = vendor; } packet.ReadXORByte(guid, 2); @@ -343,11 +341,11 @@ public static void HandleVendorInventoryList(Packet packet) packet.ReadXORByte(guid, 3); uint entry = packet.WriteGuid("GUID", guid).GetEntry(); - tempList.ForEach(v => + for(int i = 0; i < count; ++i) { - v.Entry = entry; - Storage.NpcVendors.Add(v, packet.TimeSpan); - }); + tempArray[i].Entry = entry; + Storage.NpcVendors.Add(tempArray[i], packet.TimeSpan); + } } [Parser(Opcode.SMSG_TRAINER_LIST)] diff --git a/WowPacketParserModule.V5_4_1_17538/Parsers/NpcHandler.cs b/WowPacketParserModule.V5_4_1_17538/Parsers/NpcHandler.cs index 21db57091d..a1d2ca1d92 100644 --- a/WowPacketParserModule.V5_4_1_17538/Parsers/NpcHandler.cs +++ b/WowPacketParserModule.V5_4_1_17538/Parsers/NpcHandler.cs @@ -226,10 +226,10 @@ public static void HandleVendorInventoryList(Packet packet) guid[6] = packet.ReadBit(); guid[7] = packet.ReadBit(); - var tempList = new List(); + var tempArray = new NpcVendor[count]; for (int i = 0; i < count; ++i) { - NpcVendor vendor = new NpcVendor(); + var vendor = new NpcVendor(); vendor.Item = packet.ReadInt32("Item ID", i); @@ -253,17 +253,17 @@ public static void HandleVendorInventoryList(Packet packet) packet.ReadInt32("Item Upgrade ID", i); packet.ReadInt32("Max Durability", i); - tempList.Add(vendor); + tempArray[i] = vendor; } packet.ParseBitStream(guid, 0, 2, 1, 3, 5, 7, 4, 6); uint entry = packet.WriteGuid("GUID", guid).GetEntry(); - tempList.ForEach(v => + for(int i = 0; i < count; ++i) { - v.Entry = entry; - Storage.NpcVendors.Add(v, packet.TimeSpan); - }); + tempArray[i].Entry = entry; + Storage.NpcVendors.Add(tempArray[i], packet.TimeSpan); + } } [Parser(Opcode.SMSG_TRAINER_LIST)] @@ -285,7 +285,7 @@ public static void HandleServerTrainerList(Packet packet) guid[2] = packet.ReadBit(); guid[1] = packet.ReadBit(); - var tempList = new List(); + var tempArray = new TrainerSpell[count]; for (int i = 0; i < count; ++i) { TrainerSpell trainerSpell = new TrainerSpell @@ -303,7 +303,7 @@ public static void HandleServerTrainerList(Packet packet) trainerSpell.MoneyCost = packet.ReadUInt32("MoneyCost", i); trainerSpell.ReqSkillLine = packet.ReadUInt32("ReqSkillLine", i); - tempList.Add(trainerSpell); + tempArray[i] = trainerSpell; } packet.ReadXORByte(guid, 4); @@ -325,11 +325,13 @@ public static void HandleServerTrainerList(Packet packet) packet.WriteGuid("TrainerGUID", guid); Storage.Trainers.Add(trainer, packet.TimeSpan); - tempList.ForEach(trainerSpell => + + for(int i = 0; i < count; ++i) { - trainerSpell.TrainerId = trainer.Id; - Storage.TrainerSpells.Add(trainerSpell, packet.TimeSpan); - }); + tempArray[i].TrainerId = trainer.Id; + Storage.TrainerSpells.Add(tempArray[i], packet.TimeSpan); + } + var lastGossipOption = CoreParsers.NpcHandler.LastGossipOption; if (lastGossipOption.HasSelection) Storage.GossipMenuOptionTrainers.Add(new GossipMenuOptionTrainer { MenuId = lastGossipOption.MenuId, OptionIndex = lastGossipOption.OptionIndex, TrainerId = trainer.Id }, packet.TimeSpan); diff --git a/WowPacketParserModule.V5_4_2_17658/Parsers/NpcHandler.cs b/WowPacketParserModule.V5_4_2_17658/Parsers/NpcHandler.cs index 70c1717fe1..cc1072eb73 100644 --- a/WowPacketParserModule.V5_4_2_17658/Parsers/NpcHandler.cs +++ b/WowPacketParserModule.V5_4_2_17658/Parsers/NpcHandler.cs @@ -275,10 +275,10 @@ public static void HandleVendorInventoryList(Packet packet) packet.ReadXORByte(guid, 7); packet.ReadXORByte(guid, 6); - var tempList = new List(); + var tempArray = new NpcVendor[count]; for (int i = 0; i < count; ++i) { - NpcVendor vendor = new NpcVendor + var vendor = new NpcVendor { Type = packet.ReadUInt32("Type", i) }; @@ -303,7 +303,7 @@ public static void HandleVendorInventoryList(Packet packet) if (hasCondition[i]) vendor.PlayerConditionID = packet.ReadUInt32("Condition ID", i); - tempList.Add(vendor); + tempArray[i] = vendor; } packet.ReadByte("Byte28"); @@ -318,11 +318,11 @@ public static void HandleVendorInventoryList(Packet packet) packet.WriteGuid("Guid", guid); uint entry = packet.WriteGuid("GUID", guid).GetEntry(); - tempList.ForEach(v => + for(int i = 0; i < count; ++i) { - v.Entry = entry; - Storage.NpcVendors.Add(v, packet.TimeSpan); - }); + tempArray[i].Entry = entry; + Storage.NpcVendors.Add(tempArray[i], packet.TimeSpan); + } } [Parser(Opcode.SMSG_TRAINER_LIST)] @@ -349,7 +349,7 @@ public static void HandleServerTrainerList(Packet packet) Type = packet.ReadUInt32E("TrainerType") }; - var tempList = new List(); + var tempArray = new TrainerSpell[count]; for (int i = 0; i < count; ++i) { TrainerSpell trainerSpell = new TrainerSpell @@ -366,7 +366,7 @@ public static void HandleServerTrainerList(Packet packet) trainerSpell.ReqLevel = packet.ReadByte("ReqLevel", i); trainerSpell.ReqSkillRank = packet.ReadUInt32("ReqSkillRank", i); - tempList.Add(trainerSpell); + tempArray[i] = trainerSpell; } packet.ReadXORByte(guidBytes, 7); @@ -386,11 +386,13 @@ public static void HandleServerTrainerList(Packet packet) packet.WriteGuid("TrainerGUID", guidBytes); Storage.Trainers.Add(trainer, packet.TimeSpan); - tempList.ForEach(trainerSpell => + + for(int i = 0; i < count; ++i) { - trainerSpell.TrainerId = trainer.Id; - Storage.TrainerSpells.Add(trainerSpell, packet.TimeSpan); - }); + tempArray[i].TrainerId = trainer.Id; + Storage.TrainerSpells.Add(tempArray[i], packet.TimeSpan); + } + var lastGossipOption = CoreParsers.NpcHandler.LastGossipOption; if (lastGossipOption.HasSelection) Storage.GossipMenuOptionTrainers.Add(new GossipMenuOptionTrainer { MenuId = lastGossipOption.MenuId, OptionIndex = lastGossipOption.OptionIndex, TrainerId = trainer.Id }, packet.TimeSpan); diff --git a/WowPacketParserModule.V5_4_7_17898/Parsers/NpcHandler.cs b/WowPacketParserModule.V5_4_7_17898/Parsers/NpcHandler.cs index 9d755d9977..2652919144 100644 --- a/WowPacketParserModule.V5_4_7_17898/Parsers/NpcHandler.cs +++ b/WowPacketParserModule.V5_4_7_17898/Parsers/NpcHandler.cs @@ -259,11 +259,11 @@ public static void HandleServerTrainerList(Packet packet) packet.ReadXORByte(guidBytes, 3); - var tempList = new List(); + var tempArray = new TrainerSpell[count]; for (int i = 0; i < count; ++i) { packet.ReadByteE("Usable", i); - TrainerSpell trainerSpell = new TrainerSpell + var trainerSpell = new TrainerSpell { SpellId = packet.ReadUInt32("SpellID", i), ReqSkillLine = packet.ReadUInt32("ReqSkillLine", i), @@ -276,7 +276,7 @@ public static void HandleServerTrainerList(Packet packet) trainerSpell.ReqLevel = packet.ReadByte("ReqLevel", i); trainerSpell.ReqSkillRank = packet.ReadUInt32("ReqSkillRank", i); - tempList.Add(trainerSpell); + tempArray[i] = trainerSpell; } Trainer trainer = new Trainer(); @@ -293,11 +293,13 @@ public static void HandleServerTrainerList(Packet packet) packet.WriteGuid("TrainerGUID", guidBytes); Storage.Trainers.Add(trainer, packet.TimeSpan); - tempList.ForEach(trainerSpell => + + for(int i = 0; i < count; ++i) { - trainerSpell.TrainerId = trainer.Id; - Storage.TrainerSpells.Add(trainerSpell, packet.TimeSpan); - }); + tempArray[i].TrainerId = trainer.Id; + Storage.TrainerSpells.Add(tempArray[i], packet.TimeSpan); + } + var lastGossipOption = CoreParsers.NpcHandler.LastGossipOption; if (lastGossipOption.HasSelection) Storage.GossipMenuOptionTrainers.Add(new GossipMenuOptionTrainer { MenuId = lastGossipOption.MenuId, OptionIndex = lastGossipOption.OptionIndex, TrainerId = trainer.Id }, packet.TimeSpan); @@ -355,10 +357,10 @@ public static void HandleVendorInventoryList(Packet packet) packet.ReadXORByte(guid, 3); - var tempList = new List(); + var tempArray = new NpcVendor[count]; for (int i = 0; i < count; ++i) { - NpcVendor vendor = new NpcVendor(); + var vendor = new NpcVendor(); packet.ReadInt32("Max Durability", i); vendor.Type = packet.ReadUInt32("Type", i); // 1 - item, 2 - currency uint buyCount = packet.ReadUInt32("Buy Count", i); @@ -381,7 +383,7 @@ public static void HandleVendorInventoryList(Packet packet) packet.ReadInt32("Item Upgrade ID", i); packet.ReadInt32("Display ID", i); - tempList.Add(vendor); + tempArray[i] = vendor; } packet.ReadXORByte(guid, 6); @@ -394,11 +396,11 @@ public static void HandleVendorInventoryList(Packet packet) packet.ReadXORByte(guid, 7); uint entry = packet.WriteGuid("GUID", guid).GetEntry(); - tempList.ForEach(v => + for(int i = 0; i < count; ++i) { - v.Entry = entry; - Storage.NpcVendors.Add(v, packet.TimeSpan); - }); + tempArray[i].Entry = entry; + Storage.NpcVendors.Add(tempArray[i], packet.TimeSpan); + } } [Parser(Opcode.CMSG_BUY_BANK_SLOT)] diff --git a/WowPacketParserModule.V5_4_7_17898/Parsers/SpellHandler.cs b/WowPacketParserModule.V5_4_7_17898/Parsers/SpellHandler.cs index 8370d7198f..76a9471719 100644 --- a/WowPacketParserModule.V5_4_7_17898/Parsers/SpellHandler.cs +++ b/WowPacketParserModule.V5_4_7_17898/Parsers/SpellHandler.cs @@ -56,7 +56,6 @@ public static void HandleAuraUpdate(Packet packet) guid2[0] = packet.ReadBit(); guid2[1] = packet.ReadBit(); - var auras = new List(); for (var i = 0; i < bits0; ++i) { if (hasAura[i]) diff --git a/WowPacketParserModule.V5_4_8_18291/Parsers/NpcHandler.cs b/WowPacketParserModule.V5_4_8_18291/Parsers/NpcHandler.cs index 30b5f0993f..ab5a94be4b 100644 --- a/WowPacketParserModule.V5_4_8_18291/Parsers/NpcHandler.cs +++ b/WowPacketParserModule.V5_4_8_18291/Parsers/NpcHandler.cs @@ -350,10 +350,10 @@ public static void HandleServerTrainerList(Packet packet) packet.ReadXORByte(guid, 4); - var tempList = new List(); + var tempArray = new TrainerSpell[count]; for (int i = 0; i < count; ++i) { - TrainerSpell trainerSpell = new TrainerSpell + var trainerSpell = new TrainerSpell { ReqLevel = packet.ReadByte("ReqLevel", i), MoneyCost = packet.ReadUInt32("MoneyCost", i), @@ -368,7 +368,7 @@ public static void HandleServerTrainerList(Packet packet) trainerSpell.ReqSkillRank = packet.ReadUInt32("ReqSkillRank", i); packet.ReadByteE("Usable", i); - tempList.Add(trainerSpell); + tempArray[i] = trainerSpell; } Trainer trainer = new Trainer(); @@ -385,11 +385,13 @@ public static void HandleServerTrainerList(Packet packet) packet.WriteGuid("TrainerGUID", guid); Storage.Trainers.Add(trainer, packet.TimeSpan); - tempList.ForEach(trainerSpell => + + for(int i = 0; i < count; ++i) { - trainerSpell.TrainerId = trainer.Id; - Storage.TrainerSpells.Add(trainerSpell, packet.TimeSpan); - }); + tempArray[i].TrainerId = trainer.Id; + Storage.TrainerSpells.Add(tempArray[i], packet.TimeSpan); + } + var lastGossipOption = CoreParsers.NpcHandler.LastGossipOption; if (lastGossipOption.HasSelection) Storage.GossipMenuOptionTrainers.Add(new GossipMenuOptionTrainer { MenuId = lastGossipOption.MenuId, OptionIndex = lastGossipOption.OptionIndex, TrainerId = trainer.Id }, packet.TimeSpan); @@ -436,10 +438,10 @@ public static void HandleVendorInventoryList(Packet packet) packet.ReadByte("Byte10"); - var tempList = new List(); + var tempArray = new NpcVendor[count]; for (int i = 0; i < count; ++i) { - NpcVendor vendor = new NpcVendor(); + var vendor = new NpcVendor(); packet.AddValue("unkBit", unkBit[i], i); @@ -465,17 +467,17 @@ public static void HandleVendorInventoryList(Packet packet) vendor.PlayerConditionID = packet.ReadUInt32("Condition ID", i); // +40 vendor.Slot = packet.ReadInt32("Item Position", i); // +0 - tempList.Add(vendor); + tempArray[i] = vendor; } packet.ParseBitStream(guid, 3, 7, 0, 6, 2, 1, 4, 5); uint entry = packet.WriteGuid("Guid", guid).GetEntry(); - tempList.ForEach(v => + for(int i = 0; i < count; ++i) { - v.Entry = entry; - Storage.NpcVendors.Add(v, packet.TimeSpan); - }); + tempArray[i].Entry = entry; + Storage.NpcVendors.Add(tempArray[i], packet.TimeSpan); + } } diff --git a/WowPacketParserModule.V5_4_8_18291/Parsers/PetHandler.cs b/WowPacketParserModule.V5_4_8_18291/Parsers/PetHandler.cs index c9b8983a95..b46fc4d081 100644 --- a/WowPacketParserModule.V5_4_8_18291/Parsers/PetHandler.cs +++ b/WowPacketParserModule.V5_4_8_18291/Parsers/PetHandler.cs @@ -109,7 +109,6 @@ public static void HandlePetSpells(Packet packet) guid[1] = packet.ReadBit(); const int maxCreatureSpells = 10; - var spells = new List(maxCreatureSpells); for (var i = 0; i < maxCreatureSpells; i++) // Read pet/vehicle spell ids { var spell16 = packet.ReadUInt16(); diff --git a/WowPacketParserModule.V7_0_3_22248/Parsers/UpdateHandler.cs b/WowPacketParserModule.V7_0_3_22248/Parsers/UpdateHandler.cs index 91f2934b47..46600e4c62 100644 --- a/WowPacketParserModule.V7_0_3_22248/Parsers/UpdateHandler.cs +++ b/WowPacketParserModule.V7_0_3_22248/Parsers/UpdateHandler.cs @@ -510,15 +510,14 @@ private static MovementInfo ReadMovementUpdateBlock(Packet packet, WowGuid guid, { var verticesCount = packet.ReadInt32("VerticesCount", index); var verticesTargetCount = packet.ReadInt32("VerticesTargetCount", index); - - List verticesList = new List(); + var verticesArray = new AreaTriggerTemplateVertices[verticesCount]; areaTriggerTemplate.Data[0] = packet.ReadSingle("Height", index); areaTriggerTemplate.Data[1] = packet.ReadSingle("HeightTarget", index); for (uint i = 0; i < verticesCount; ++i) { - AreaTriggerTemplateVertices areaTriggerTemplateVertices = new AreaTriggerTemplateVertices + var areaTriggerTemplateVertices = new AreaTriggerTemplateVertices { AreaTriggerId = guid.GetEntry(), Idx = i @@ -529,18 +528,18 @@ private static MovementInfo ReadMovementUpdateBlock(Packet packet, WowGuid guid, areaTriggerTemplateVertices.VerticeX = vertices.X; areaTriggerTemplateVertices.VerticeY = vertices.Y; - verticesList.Add(areaTriggerTemplateVertices); + verticesArray[i] = areaTriggerTemplateVertices; } for (var i = 0; i < verticesTargetCount; ++i) { Vector2 verticesTarget = packet.ReadVector2("VerticesTarget", index, i); - verticesList[i].VerticeTargetX = verticesTarget.X; - verticesList[i].VerticeTargetY = verticesTarget.Y; + verticesArray[i].VerticeTargetX = verticesTarget.X; + verticesArray[i].VerticeTargetY = verticesTarget.Y; } - foreach (AreaTriggerTemplateVertices vertice in verticesList) + foreach (var vertice in verticesArray) Storage.AreaTriggerTemplatesVertices.Add(vertice); }