mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-08-27 05:18:43 -05:00
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:
@@ -205,7 +205,7 @@ public override string GetBoxName(int box)
|
||||
|
||||
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 @@ public override void SetBoxName(int box, string value)
|
||||
|
||||
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);
|
||||
|
||||
@@ -23,7 +23,7 @@ public sealed class BoxLayout8b : SaveBlock, IBoxDetailName
|
||||
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 @@ public string GetTeamName(int team)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user