BDSP: Handle uninitialized box names

span refactoring didn't catch this
also apply same change for gen4 battle revolution string reads
This commit is contained in:
Kurt 2022-02-11 10:43:27 -08:00
parent bb2b8e74c3
commit 574a7f43a0
2 changed files with 4 additions and 4 deletions

View file

@ -205,7 +205,7 @@ namespace PKHeX.Core
int ofs = BoxName + (box * BoxNameLength); int ofs = BoxName + (box * BoxNameLength);
var span = Data.AsSpan(ofs, BoxNameLength); var span = Data.AsSpan(ofs, BoxNameLength);
if (span.Count((byte)0) == span.Length) if (ReadUInt16BigEndian(span) == 0)
return $"BOX {box + 1}"; return $"BOX {box + 1}";
return GetString(ofs, BoxNameLength); return GetString(ofs, BoxNameLength);
} }
@ -217,7 +217,7 @@ namespace PKHeX.Core
int ofs = BoxName + (box * BoxNameLength); int ofs = BoxName + (box * BoxNameLength);
var span = Data.AsSpan(ofs, BoxNameLength); var span = Data.AsSpan(ofs, BoxNameLength);
if (span.Count((byte)0) == span.Length) if (ReadUInt16BigEndian(span) == 0)
return; return;
SetString(span, value.AsSpan(), BoxNameLength / 2, StringConverterOption.ClearZero); SetString(span, value.AsSpan(), BoxNameLength / 2, StringConverterOption.ClearZero);

View file

@ -23,7 +23,7 @@ namespace PKHeX.Core
public string GetBoxName(int box) public string GetBoxName(int box)
{ {
var span = Data.AsSpan(Offset + GetBoxNameOffset(box), SAV6.LongStringLength); 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 $"Box {box + 1}";
return SAV.GetString(span); return SAV.GetString(span);
} }
@ -38,7 +38,7 @@ namespace PKHeX.Core
{ {
var offset = Offset + GetTeamNameOffset(team); var offset = Offset + GetTeamNameOffset(team);
var span = Data.AsSpan(offset, TeamNameLength); var span = Data.AsSpan(offset, TeamNameLength);
if (span.Count((byte)0) == span.Length) if (ReadUInt16LittleEndian(span) == 0)
return $"Team {team + 1}"; return $"Team {team + 1}";
return SAV.GetString(span); return SAV.GetString(span);
} }