mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-26 22:10:21 +00:00
Use slice operation instead of linq chain
Reuse IsRangeAll for smdemo detect reset dragdrop on dropping folder (early returned)
This commit is contained in:
parent
78b7409e77
commit
7819c16792
13 changed files with 23 additions and 22 deletions
|
@ -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); }
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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++)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -216,6 +216,7 @@ namespace PKHeX.WinForms.Controls
|
|||
if (Directory.Exists(files[0])) // folder
|
||||
{
|
||||
SE.LoadBoxes(out string _, files[0]);
|
||||
Drag.Reset();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue