ZA Blank save indicate as -MD

Needed to change the blank block's type. Technically I could have made SaveRevision a readonly field rather than computed...
This commit is contained in:
Kurt 2025-12-12 13:14:32 -06:00
parent aee2d1a556
commit e89bf3a416
2 changed files with 31 additions and 6 deletions

View File

@ -45,6 +45,31 @@ public void ChangeBooleanType(SCTypeCode value)
Type = value;
}
/// <summary>
/// Changes the block's data type. Use with caution.
/// </summary>
/// <param name="value">New data type to set.</param>
/// <remarks>Will throw if the requested block state changes are incorrect.</remarks>
public void ChangeStoredType(SCTypeCode value)
{
var noData = Data.Length == 0;
var isBoolean = value is SCTypeCode.Bool1 or SCTypeCode.Bool2;
if (noData != isBoolean)
throw new InvalidOperationException($"Cannot change {Type} to {value}.");
if (value is SCTypeCode.Array)
{
}
else if (!isBoolean)
{
var size = value.GetTypeSize();
if (Data.Length != size)
throw new InvalidOperationException($"Cannot change {Type} to {value}.");
}
Type = value;
}
/// <summary>
/// Replaces the current <see cref="Data"/> with a same-sized array <see cref="value"/>.
/// </summary>

View File

@ -21,7 +21,11 @@ public SAV9ZA()
{
AllBlocks = BlankBlocks9a.GetBlankBlocks();
Blocks = new SaveBlockAccessor9ZA(this);
SaveRevision = BlankBlocks9a.BlankRevision;
var revision = Blocks.GetBlock(SaveBlockAccessor9ZA.KSaveRevision);
revision.ChangeStoredType(SCTypeCode.UInt64);
revision.SetValue((ulong)BlankBlocks9a.BlankRevision);
Initialize();
ClearBoxes();
}
@ -38,11 +42,7 @@ public override void CopyChangesFrom(SaveFile sav)
}
public int SaveRevision
{
get => (int)GetValue<ulong>(SaveBlockAccessor9ZA.KSaveRevision);
private init => SetValue(SaveBlockAccessor9ZA.KSaveRevision, (ulong)value);
}
public int SaveRevision => (int)GetValue<ulong>(SaveBlockAccessor9ZA.KSaveRevision);
public string SaveRevisionString => SaveRevision switch
{