diff --git a/PKHeX.Core/MysteryGifts/PL6.cs b/PKHeX.Core/MysteryGifts/PL6.cs index 7815c1a8d..df968f30f 100644 --- a/PKHeX.Core/MysteryGifts/PL6.cs +++ b/PKHeX.Core/MysteryGifts/PL6.cs @@ -44,12 +44,12 @@ namespace PKHeX.Core public uint Flags_6 { get => BitConverter.ToUInt32(Data, 0x3E1); set => BitConverter.GetBytes(value).CopyTo(Data, 0x3E1); } // Pokémon - public PL6_PKM Poke_1 { get => new PL6_PKM(Data.Skip(0x09D).Take(PL6_PKM.Size).ToArray()); set => value.Data.CopyTo(Data, 0x09D); } - public PL6_PKM Poke_2 { get => new PL6_PKM(Data.Skip(0x145).Take(PL6_PKM.Size).ToArray()); set => value.Data.CopyTo(Data, 0x145); } - public PL6_PKM Poke_3 { get => new PL6_PKM(Data.Skip(0x1ED).Take(PL6_PKM.Size).ToArray()); set => value.Data.CopyTo(Data, 0x1ED); } - public PL6_PKM Poke_4 { get => new PL6_PKM(Data.Skip(0x295).Take(PL6_PKM.Size).ToArray()); set => value.Data.CopyTo(Data, 0x295); } - public PL6_PKM Poke_5 { get => new PL6_PKM(Data.Skip(0x33D).Take(PL6_PKM.Size).ToArray()); set => value.Data.CopyTo(Data, 0x33D); } - public PL6_PKM Poke_6 { get => new PL6_PKM(Data.Skip(0x3E5).Take(PL6_PKM.Size).ToArray()); set => value.Data.CopyTo(Data, 0x3E5); } + public PL6_PKM Poke_1 { get => new PL6_PKM(Data.Slice(0x09D, PL6_PKM.Size)); set => value.Data.CopyTo(Data, 0x09D); } + public PL6_PKM Poke_2 { get => new PL6_PKM(Data.Slice(0x145, PL6_PKM.Size)); set => value.Data.CopyTo(Data, 0x145); } + public PL6_PKM Poke_3 { get => new PL6_PKM(Data.Slice(0x1ED, PL6_PKM.Size)); set => value.Data.CopyTo(Data, 0x1ED); } + public PL6_PKM Poke_4 { get => new PL6_PKM(Data.Slice(0x295, PL6_PKM.Size)); set => value.Data.CopyTo(Data, 0x295); } + public PL6_PKM Poke_5 { get => new PL6_PKM(Data.Slice(0x33D, PL6_PKM.Size)); set => value.Data.CopyTo(Data, 0x33D); } + public PL6_PKM Poke_6 { get => new PL6_PKM(Data.Slice(0x3E5, PL6_PKM.Size)); set => value.Data.CopyTo(Data, 0x3E5); } // Item Properties public int Item_1 { get => BitConverter.ToUInt16(Data, 0x489); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x489); } diff --git a/PKHeX.Core/PKM/PK4.cs b/PKHeX.Core/PKM/PK4.cs index cc20afcb0..0bfa5607a 100644 --- a/PKHeX.Core/PKM/PK4.cs +++ b/PKHeX.Core/PKM/PK4.cs @@ -324,7 +324,7 @@ namespace PKHeX.Core public override int Stat_SPE { get => BitConverter.ToUInt16(Data, 0x96); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x96); } public override int Stat_SPA { get => BitConverter.ToUInt16(Data, 0x98); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x98); } public override int Stat_SPD { get => BitConverter.ToUInt16(Data, 0x9A); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x9A); } - public byte[] HeldMailData { get => Data.Skip(0x9C).Take(0x38).ToArray(); set => value.CopyTo(Data, 0x9C); } + public byte[] HeldMailData { get => Data.Slice(0x9C, 0x38); set => value.CopyTo(Data, 0x9C); } #endregion // Methods diff --git a/PKHeX.Core/Saves/SAV3Colosseum.cs b/PKHeX.Core/Saves/SAV3Colosseum.cs index e90eb2dfb..16641ae44 100644 --- a/PKHeX.Core/Saves/SAV3Colosseum.cs +++ b/PKHeX.Core/Saves/SAV3Colosseum.cs @@ -132,7 +132,7 @@ namespace PKHeX.Core SetChecksums(); // Get updated save slot data - byte[] digest = Data.Skip(Data.Length - 20).Take(20).ToArray(); + byte[] digest = Data.Slice(Data.Length - 20, 20); byte[] newSAV = EncryptColosseum(Data, digest); // Put save slot back in original save data @@ -275,7 +275,7 @@ namespace PKHeX.Core newHC -= BigEndian.ToInt32(D, 0); newHC -= BigEndian.ToInt32(D, 4); - byte[] chk = data.Skip(data.Length - 20).Take(20).ToArray(); + byte[] chk = data.Slice(data.Length - 20, 20); bool header = newHC == oldHC; bool body = chk.SequenceEqual(checksum); diff --git a/PKHeX.Core/Saves/SAV3XD.cs b/PKHeX.Core/Saves/SAV3XD.cs index 9795961ea..ea65e03d0 100644 --- a/PKHeX.Core/Saves/SAV3XD.cs +++ b/PKHeX.Core/Saves/SAV3XD.cs @@ -87,7 +87,7 @@ namespace PKHeX.Core // Purifier = subOffsets[14] + 0xA8; StrategyMemo = new StrategyMemo(Data, Memo, xd: true); - ShadowInfo = new ShadowInfoTableXD(Data.Skip(Shadow).Take(subLength[7]).ToArray()); + ShadowInfo = new ShadowInfoTableXD(Data.Slice(Shadow, subLength[7])); } private void Initialize() diff --git a/PKHeX.Core/Saves/SAV7.cs b/PKHeX.Core/Saves/SAV7.cs index 1e63f14c1..5ac615658 100644 --- a/PKHeX.Core/Saves/SAV7.cs +++ b/PKHeX.Core/Saves/SAV7.cs @@ -40,7 +40,7 @@ namespace PKHeX.Core private void ReloadBattleTeams() { - var demo = this is SAV7SM && Data.Skip(PCLayout).Take(0x4C4).All(z => z == 0); // up to Battle Box values + var demo = this is SAV7SM && Data.IsRangeAll(0, PCLayout, 0x4C4); // up to Battle Box values if (demo || !Exportable) { BoxLayout.ClearBattleTeams(); diff --git a/PKHeX.Core/Saves/Substructures/Battle Videos/BV6.cs b/PKHeX.Core/Saves/Substructures/Battle Videos/BV6.cs index 615b31ca1..c1d168ada 100644 --- a/PKHeX.Core/Saves/Substructures/Battle Videos/BV6.cs +++ b/PKHeX.Core/Saves/Substructures/Battle Videos/BV6.cs @@ -92,7 +92,7 @@ namespace PKHeX.Core { int offset = start + (PKX.SIZE_6PARTY*((t * 6) + p)); offset += 8*(((t * 6) + p)/6); // 8 bytes padding between teams - Teams[t][p] = new PK6(Data.Skip(offset).Take(PKX.SIZE_6PARTY).ToArray()) {Identifier = $"Team {t}, Slot {p}"}; + Teams[t][p] = new PK6(Data.Slice(offset, PKX.SIZE_6PARTY)) {Identifier = $"Team {t}, Slot {p}"}; } } return Teams; diff --git a/PKHeX.Core/Saves/Substructures/Battle Videos/BV7.cs b/PKHeX.Core/Saves/Substructures/Battle Videos/BV7.cs index d5de62e74..da02d0e89 100644 --- a/PKHeX.Core/Saves/Substructures/Battle Videos/BV7.cs +++ b/PKHeX.Core/Saves/Substructures/Battle Videos/BV7.cs @@ -34,7 +34,7 @@ namespace PKHeX.Core for (int p = 0; p < 6; p++) { int offset = offsets[t] + (PKX.SIZE_6PARTY * p); - Teams[t][p] = new PK7(Data.Skip(offset).Take(PKX.SIZE_6STORED).ToArray()) {Identifier = $"Team {t}, Slot {p}"}; + Teams[t][p] = new PK7(Data.Slice(offset, PKX.SIZE_6STORED)) {Identifier = $"Team {t}, Slot {p}"}; } } return Teams; diff --git a/PKHeX.Core/Saves/Substructures/Gen3/SecretBase3.cs b/PKHeX.Core/Saves/Substructures/Gen3/SecretBase3.cs index 2cea079f7..85de122db 100644 --- a/PKHeX.Core/Saves/Substructures/Gen3/SecretBase3.cs +++ b/PKHeX.Core/Saves/Substructures/Gen3/SecretBase3.cs @@ -44,19 +44,19 @@ namespace PKHeX.Core public byte[] Decorations { - get => Data.Skip(Offset + 0x12).Take(0x10).ToArray(); + get => Data.Slice(Offset + 0x12, 0x10); set => value.CopyTo(Data, Offset + 0x12); } public byte[] DecorationCoordinates { - get => Data.Skip(Offset + 0x22).Take(0x10).ToArray(); + get => Data.Slice(Offset + 0x22, 0x10); set => value.CopyTo(Data, Offset + 0x22); } public SecretBase3Team Team { - get => new SecretBase3Team(Data.Skip(Offset + 50).Take(72).ToArray()); + get => new SecretBase3Team(Data.Slice(Offset + 50, 72)); set => value.Write().CopyTo(Data, Offset + 50); } diff --git a/PKHeX.Core/Saves/Substructures/Gen3/StrategyMemo.cs b/PKHeX.Core/Saves/Substructures/Gen3/StrategyMemo.cs index b448db65a..eef60cd67 100644 --- a/PKHeX.Core/Saves/Substructures/Gen3/StrategyMemo.cs +++ b/PKHeX.Core/Saves/Substructures/Gen3/StrategyMemo.cs @@ -18,7 +18,7 @@ namespace PKHeX.Core int count = BigEndian.ToInt16(input, offset); if (count > 500) count = 500; - _unk = input.Skip(offset + 2).Take(2).ToArray(); + _unk = input.Slice(offset + 2, 2); for (int i = 0; i < count; i++) { var entry = Read(input, offset, i); diff --git a/PKHeX.Core/Saves/Substructures/Gen5/CGearBackground.cs b/PKHeX.Core/Saves/Substructures/Gen5/CGearBackground.cs index 857c8c81c..5cdd77ed2 100644 --- a/PKHeX.Core/Saves/Substructures/Gen5/CGearBackground.cs +++ b/PKHeX.Core/Saves/Substructures/Gen5/CGearBackground.cs @@ -52,9 +52,9 @@ namespace PKHeX.Core _cgb = data; } - byte[] Region1 = data.Take(0x1FE0).ToArray(); - byte[] ColorData = data.Skip(0x1FE0).Take(0x20).ToArray(); - byte[] Region2 = data.Skip(0x2000).Take(0x600).ToArray(); + byte[] Region1 = data.Slice(0, 0x1FE0); + byte[] ColorData = data.Slice(0x1FE0, 0x20); + byte[] Region2 = data.Slice(0x2000, 0x600); ColorPalette = new int[0x10]; for (int i = 0; i < 0x10; i++) diff --git a/PKHeX.Core/Saves/Substructures/Misc/FestaFacility.cs b/PKHeX.Core/Saves/Substructures/Misc/FestaFacility.cs index 2e74f18d8..6ddb06ef4 100644 --- a/PKHeX.Core/Saves/Substructures/Misc/FestaFacility.cs +++ b/PKHeX.Core/Saves/Substructures/Misc/FestaFacility.cs @@ -35,7 +35,7 @@ namespace PKHeX.Core public uint UsedRandStat { get => BitConverter.ToUInt32(Data, 0x2C); set => BitConverter.GetBytes(value).CopyTo(Data, 0x2C); } public int NPC { get => Math.Max(0, BitConverter.ToInt32(Data, 0x30)); set => BitConverter.GetBytes(Math.Max(0, value)).CopyTo(Data, 0x30); } - public byte[] TrainerFesID { get => Data.Skip(0x34).Take(12).ToArray(); set => value.CopyTo(Data, 0x34); } + public byte[] TrainerFesID { get => Data.Slice(0x34, 0xC); set => value.CopyTo(Data, 0x34); } public int ExchangeLeftCount { get => Data[0x40]; set => Data[0x40] = (byte)value; } // used when Type=Exchange public int GetMessage(int index) diff --git a/PKHeX.WinForms/Controls/SAV Editor/SlotChangeManager.cs b/PKHeX.WinForms/Controls/SAV Editor/SlotChangeManager.cs index d50949bcc..a7a58fbf6 100644 --- a/PKHeX.WinForms/Controls/SAV Editor/SlotChangeManager.cs +++ b/PKHeX.WinForms/Controls/SAV Editor/SlotChangeManager.cs @@ -216,6 +216,7 @@ namespace PKHeX.WinForms.Controls if (Directory.Exists(files[0])) // folder { SE.LoadBoxes(out string _, files[0]); + Drag.Reset(); return; } diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_Link6.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_Link6.cs index fa299986a..9e94a7db5 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_Link6.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_Link6.cs @@ -28,7 +28,7 @@ namespace PKHeX.WinForms Close(); return; } - data = data.Skip(0x1FF).Take(PL6.Size).ToArray(); + data = data.Slice(0x1FF, PL6.Size); LoadLinkData(data); }