mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-03-21 17:48:28 -05:00
Minor tweaks
This commit is contained in:
parent
73536187cf
commit
f10b6c5196
|
|
@ -91,29 +91,37 @@ public static bool IsFiltered(ReadOnlySpan<char> message, EntityContext current,
|
|||
return IsFilteredLookBack(message, current, original, out type, out regMatch);
|
||||
}
|
||||
|
||||
private static bool IsFilteredCurrentOnly(ReadOnlySpan<char> message, EntityContext current, EntityContext original, out int regMatch)
|
||||
private static bool IsFilteredCurrentOnly(ReadOnlySpan<char> message, EntityContext current, EntityContext original, out int regMatch) => current switch
|
||||
{
|
||||
// Ancient: None (Gen1-3), or simply blocked from online trading (Gen4).
|
||||
|
||||
// Past: Game driven
|
||||
EntityContext.Gen5 => WordFilter5.IsFiltered(message, out regMatch),
|
||||
|
||||
EntityContext.Gen6 => WordFilter3DS.IsFilteredGen6(message, out regMatch),
|
||||
EntityContext.Gen7 when original is EntityContext.Gen6
|
||||
=> WordFilter3DS.IsFilteredGen6(message, out regMatch),
|
||||
|
||||
EntityContext.Gen7 => WordFilter3DS.IsFilteredGen7(message, out regMatch),
|
||||
|
||||
// Future: Console word filters
|
||||
_ => current.GetConsole() switch
|
||||
{
|
||||
GameConsole.NX => WordFilterNX.IsFiltered(message, out regMatch, original),
|
||||
_ => NoFilter(out regMatch),
|
||||
},
|
||||
};
|
||||
|
||||
private static bool NoFilter(out int regMatch)
|
||||
{
|
||||
regMatch = 0;
|
||||
return current switch
|
||||
{
|
||||
EntityContext.Gen5 => WordFilter5.IsFiltered(message, out regMatch),
|
||||
|
||||
EntityContext.Gen6 => WordFilter3DS.IsFilteredGen6(message, out regMatch),
|
||||
EntityContext.Gen7 when original is EntityContext.Gen6
|
||||
=> WordFilter3DS.IsFilteredGen6(message, out regMatch),
|
||||
|
||||
EntityContext.Gen7 => WordFilter3DS.IsFilteredGen7(message, out regMatch),
|
||||
_ => current.GetConsole() switch
|
||||
{
|
||||
GameConsole.NX => WordFilterNX.IsFiltered(message, out regMatch, original),
|
||||
_ => false,
|
||||
},
|
||||
};
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool IsFilteredLookBack(ReadOnlySpan<char> message, EntityContext current, EntityContext original, out WordFilterType type, out int regMatch)
|
||||
{
|
||||
// Switch 2 backwards transfer? Won't know for another couple years.
|
||||
// Summer 2025: We've been told they won't allow ZA+ to transfer back. Time will tell.
|
||||
if (WordFilterNX.IsFiltered(message, out regMatch, original))
|
||||
{
|
||||
type = WordFilterType.NintendoSwitch;
|
||||
|
|
|
|||
|
|
@ -22,11 +22,10 @@ public sealed class SAV1 : SaveFile, ILangDeviantSave, IEventFlagArray, IEventWo
|
|||
/// <summary>
|
||||
/// Rather than deal with managing lists on each slot read/write, store all sequentially in a single buffer.
|
||||
/// </summary>
|
||||
private readonly byte[] Reserved = new byte[SIZE_RESERVED];
|
||||
private readonly Memory<byte> Reserved = new byte[0x8000]; // chunk of RAM to store unpacked [..box, ..party, ..etc] data
|
||||
|
||||
private const int SIZE_RESERVED = 0x8000; // unpacked box data
|
||||
protected override Span<byte> BoxBuffer => Reserved;
|
||||
protected override Span<byte> PartyBuffer => Reserved;
|
||||
protected override Span<byte> BoxBuffer => Reserved.Span;
|
||||
protected override Span<byte> PartyBuffer => Reserved.Span;
|
||||
private readonly SAV1Offsets Offsets;
|
||||
|
||||
public override PersonalTable1 Personal { get; }
|
||||
|
|
@ -441,7 +440,7 @@ public override IReadOnlyList<InventoryPouch> Inventory
|
|||
public Memory<byte> GetDaycareSlot(int index)
|
||||
{
|
||||
ArgumentOutOfRangeException.ThrowIfNotEqual(index, 0, nameof(index));
|
||||
return Reserved.AsMemory(DaycareOffset, SIZE_STORED);
|
||||
return Reserved.Slice(DaycareOffset, SIZE_STORED);
|
||||
}
|
||||
|
||||
public bool IsDaycareOccupied(int index)
|
||||
|
|
|
|||
|
|
@ -22,12 +22,10 @@ public sealed class SAV2 : SaveFile, ILangDeviantSave, IEventFlagArray, IEventWo
|
|||
/// <summary>
|
||||
/// Rather than deal with managing lists on each slot read/write, store all sequentially in a single buffer.
|
||||
/// </summary>
|
||||
private readonly byte[] Reserved = new byte[SIZE_RESERVED];
|
||||
private readonly Memory<byte> Reserved = new byte[0x8000]; // chunk of RAM to store unpacked [..box, ..party, ..etc] data
|
||||
|
||||
private const int SIZE_RESERVED = 0x8000; // unpacked box data
|
||||
|
||||
protected override Span<byte> BoxBuffer => Reserved;
|
||||
protected override Span<byte> PartyBuffer => Reserved;
|
||||
protected override Span<byte> BoxBuffer => Reserved.Span;
|
||||
protected override Span<byte> PartyBuffer => Reserved.Span;
|
||||
|
||||
private readonly SAV2Offsets Offsets;
|
||||
|
||||
|
|
@ -290,9 +288,9 @@ private ushort GetChecksum()
|
|||
|
||||
protected override void SetChecksums()
|
||||
{
|
||||
ushort accum = GetChecksum();
|
||||
WriteUInt16LittleEndian(Data[Offsets.OverallChecksumPosition..], accum);
|
||||
WriteUInt16LittleEndian(Data[Offsets.OverallChecksumPosition2..], accum);
|
||||
ushort checksum = GetChecksum();
|
||||
WriteUInt16LittleEndian(Data[Offsets.OverallChecksumPosition..], checksum);
|
||||
WriteUInt16LittleEndian(Data[Offsets.OverallChecksumPosition2..], checksum);
|
||||
}
|
||||
|
||||
public override bool ChecksumsValid => !ChecksumInfo.Contains("Invalid");
|
||||
|
|
@ -301,12 +299,12 @@ public override string ChecksumInfo
|
|||
{
|
||||
get
|
||||
{
|
||||
ushort accum = GetChecksum();
|
||||
ushort actual = ReadUInt16LittleEndian(Data[Offsets.OverallChecksumPosition..]);
|
||||
ushort checksum = GetChecksum();
|
||||
ushort actual1 = ReadUInt16LittleEndian(Data[Offsets.OverallChecksumPosition..]);
|
||||
ushort actual2 = ReadUInt16LittleEndian(Data[Offsets.OverallChecksumPosition2..]);
|
||||
|
||||
bool checksum1Valid = (accum == actual);
|
||||
bool checksum2Valid = (accum == actual2);
|
||||
bool checksum1Valid = (checksum == actual1);
|
||||
bool checksum2Valid = (checksum == actual2);
|
||||
static string valid(bool s) => s ? "Valid" : "Invalid";
|
||||
return $"Checksum 1 {valid(checksum1Valid)}, Checksum 2 {valid(checksum2Valid)}.";
|
||||
}
|
||||
|
|
@ -575,8 +573,8 @@ private int GetDaycareOffset(int index)
|
|||
|
||||
public int DaycareSlotCount => 2;
|
||||
private int GetDaycareSlotOffset(int slot) => GetPartyOffset(6 + slot);
|
||||
public Memory<byte> GetDaycareSlot(int slot) => Reserved.AsMemory(GetDaycareSlotOffset(slot), SIZE_STORED);
|
||||
public Memory<byte> GetDaycareEgg() => Reserved.AsMemory(GetDaycareSlotOffset(2), SIZE_STORED);
|
||||
public Memory<byte> GetDaycareSlot(int slot) => Reserved.Slice(GetDaycareSlotOffset(slot), SIZE_STORED);
|
||||
public Memory<byte> GetDaycareEgg() => Reserved.Slice(GetDaycareSlotOffset(2), SIZE_STORED);
|
||||
public bool IsDaycareOccupied(int slot) => (DaycareFlagByte(slot) & 1) != 0;
|
||||
|
||||
public void SetDaycareOccupied(int slot, bool occupied)
|
||||
|
|
|
|||
|
|
@ -341,11 +341,12 @@ private void ReloadBattlePassList()
|
|||
|
||||
for (int i = 0; i < BattlePassAccessor.PASS_COUNT; i++)
|
||||
{
|
||||
string type = WinFormsTranslator.TranslateEnum(SAV.BattlePasses.GetPassType(i), Main.CurrentLanguage);
|
||||
BattlePass pass = GetBattlePassReference(i);
|
||||
string name = pass.Name;
|
||||
if ((!pass.Rental && !pass.Issued) || string.IsNullOrWhiteSpace(name))
|
||||
var pass = GetBattlePassReference(i);
|
||||
var name = pass.Name;
|
||||
if (string.IsNullOrWhiteSpace(name) || pass is { Rental: false, Issued: false })
|
||||
name = None;
|
||||
|
||||
var type = WinFormsTranslator.TranslateEnum(SAV.BattlePasses.GetPassType(i), Main.CurrentLanguage);
|
||||
LB_Passes.Items[i] = $"{i + 1:00} {type}/{name}";
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user