feat: anchored-time infrastructure with a save-start anchor in idx v5
WriteAnchoredTime stores the absolute value; ReadAnchoredTime re-bases it by the elapsed time since the loaded save started, so downtime does not age it and an unchanged value serializes to identical bytes. Min/MaxValue pass through unshifted and shifts saturate instead of overflowing. The shift rides the reader instance, so parallel per-persistence loads and single-file restores each see their own file's anchor. World.SaveStartTime is stamped the moment the world freezes for a snapshot - one anchor for the whole save - and written into the idx v5 header. Loading an idx v5 computes the shift and applies it to that persistence's bin readers; v4 and older carry no anchor and read with a zero shift, which existing hand-written-header tests already pin. Nothing serializes anchored values yet; field conversions follow separately. Covered by unit round-trip tests and an end-to-end persistence test that re-bases across a simulated two-hour downtime. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
541dbc5ac5
commit
319dcacba7
9 changed files with 279 additions and 5 deletions
|
|
@ -74,6 +74,12 @@ public sealed unsafe class BinaryFileReader : IDisposable, IGenericReader
|
|||
/// </summary>
|
||||
public long Position => _reader.Position;
|
||||
|
||||
public TimeSpan AnchoredTimeShift
|
||||
{
|
||||
get => _reader.AnchoredTimeShift;
|
||||
set => _reader.AnchoredTimeShift = value;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_accessor?.SafeMemoryMappedViewHandle.ReleasePointer();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue