Minor tweaks

Fix boxbin load being ignored
This commit is contained in:
Kurt 2023-03-28 11:29:29 -07:00
parent 5c13183d02
commit e6ebd20d83
3 changed files with 19 additions and 6 deletions

View file

@ -863,7 +863,6 @@ public abstract class SaveFile : ITrainerInfo, IGameValueLimit, IBoxDetailWallpa
if (data.Length != expectLength) if (data.Length != expectLength)
return false; return false;
var BD = BoxData;
var entryLength = SIZE_BOXSLOT; var entryLength = SIZE_BOXSLOT;
for (int i = 0, ctr = start; i < data.Length; i += entryLength) for (int i = 0, ctr = start; i < data.Length; i += entryLength)
{ {
@ -874,7 +873,6 @@ public abstract class SaveFile : ITrainerInfo, IGameValueLimit, IBoxDetailWallpa
var pk = GetPKM(arr); var pk = GetPKM(arr);
SetBoxSlotAtIndex(pk, ctr++); SetBoxSlotAtIndex(pk, ctr++);
} }
BoxData = BD;
return true; return true;
} }
#endregion #endregion

View file

@ -1,4 +1,5 @@
using System.IO; using System;
using System.IO;
namespace PKHeX.Core; namespace PKHeX.Core;
@ -10,6 +11,20 @@ public static partial class Util
/// <returns>New string without any invalid characters.</returns> /// <returns>New string without any invalid characters.</returns>
public static string CleanFileName(string fileName) public static string CleanFileName(string fileName)
{ {
return string.Concat(fileName.Split(Path.GetInvalidFileNameChars())); Span<char> result = stackalloc char[fileName.Length];
int ctr = GetCleanFileName(fileName, result);
return new string(result[..ctr]);
}
private static int GetCleanFileName(ReadOnlySpan<char> input, Span<char> output)
{
ReadOnlySpan<char> invalid = Path.GetInvalidFileNameChars();
int ctr = 0;
foreach (var c in input)
{
if (!invalid.Contains(c))
output[ctr++] = c;
}
return ctr;
} }
} }

View file

@ -1,4 +1,4 @@
using System; using System;
namespace PKHeX.Core; namespace PKHeX.Core;
@ -28,7 +28,7 @@ public static class UpdateUtil
if (second == -1) if (second == -1)
return null; return null;
var tagString = responseJson[first..second]; var tagString = responseJson.AsSpan()[first..second];
return !Version.TryParse(tagString, out var latestVersion) ? null : latestVersion; return !Version.TryParse(tagString, out var latestVersion) ? null : latestVersion;
} }
} }