From 574a7f43a05cae6afe8df8b7608caed8d511f769 Mon Sep 17 00:00:00 2001 From: Kurt Date: Fri, 11 Feb 2022 10:43:27 -0800 Subject: [PATCH] BDSP: Handle uninitialized box names span refactoring didn't catch this also apply same change for gen4 battle revolution string reads --- PKHeX.Core/Saves/SAV4BR.cs | 4 ++-- PKHeX.Core/Saves/Substructures/Gen8/BS/BoxLayout8b.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/PKHeX.Core/Saves/SAV4BR.cs b/PKHeX.Core/Saves/SAV4BR.cs index 86f602f11..ac0a432fa 100644 --- a/PKHeX.Core/Saves/SAV4BR.cs +++ b/PKHeX.Core/Saves/SAV4BR.cs @@ -205,7 +205,7 @@ namespace PKHeX.Core int ofs = BoxName + (box * BoxNameLength); var span = Data.AsSpan(ofs, BoxNameLength); - if (span.Count((byte)0) == span.Length) + if (ReadUInt16BigEndian(span) == 0) return $"BOX {box + 1}"; return GetString(ofs, BoxNameLength); } @@ -217,7 +217,7 @@ namespace PKHeX.Core int ofs = BoxName + (box * BoxNameLength); var span = Data.AsSpan(ofs, BoxNameLength); - if (span.Count((byte)0) == span.Length) + if (ReadUInt16BigEndian(span) == 0) return; SetString(span, value.AsSpan(), BoxNameLength / 2, StringConverterOption.ClearZero); diff --git a/PKHeX.Core/Saves/Substructures/Gen8/BS/BoxLayout8b.cs b/PKHeX.Core/Saves/Substructures/Gen8/BS/BoxLayout8b.cs index 6b2447892..d4ecfaa01 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/BS/BoxLayout8b.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/BS/BoxLayout8b.cs @@ -23,7 +23,7 @@ namespace PKHeX.Core public string GetBoxName(int box) { var span = Data.AsSpan(Offset + GetBoxNameOffset(box), SAV6.LongStringLength); - if (span.Count((byte)0) == span.Length) + if (ReadUInt16LittleEndian(span) == 0) return $"Box {box + 1}"; return SAV.GetString(span); } @@ -38,7 +38,7 @@ namespace PKHeX.Core { var offset = Offset + GetTeamNameOffset(team); var span = Data.AsSpan(offset, TeamNameLength); - if (span.Count((byte)0) == span.Length) + if (ReadUInt16LittleEndian(span) == 0) return $"Team {team + 1}"; return SAV.GetString(span); }