## Summary The save-stability infrastructure consumed by generator v3's `[AnchoredDateTime]`: anchored timestamps are written as **absolute values** and re-based once at load by the elapsed time since the save started — so downtime doesn't age them, and an unchanged entity serializes to identical bytes (the prerequisite for replacing delta-time encodings, which rewrite every entity on every save). ## Design - **`WriteAnchoredTime` / `ReadAnchoredTime`** on `IGenericWriter`/`IGenericReader`. The read side applies the reader's `AnchoredTimeShift`; `Min/MaxValue` sentinels pass through unshifted, and shifts saturate instead of overflowing. - **`World.SaveStartTime`** is stamped the moment the world freezes for a snapshot — one anchor for the entire save, no per-persistence skew. - **idx v5**: the anchor ticks sit in the header right after the version. The anchor travels with the file it re-anchors, so a single idx+bin pair restored from a backup is self-describing, and anchor presence is guaranteed by the same version gate as the record format — there is no separate anchor file to lose. - **The shift rides the reader instance** (`BufferReader`, `UnmanagedDataReader`, `BinaryFileReader` delegating), not a static — parallel per-persistence loads and ad-hoc restores each see their own file's anchor. idx v4 and older read with a zero shift. ## Scope Behavior-neutral: nothing serializes anchored values yet (`Item.DecayResetTime` and the `[DeltaDateTime]` field migrations come separately, with their own version bumps). Saves written from this branch are idx v5; loading v4/v3 saves is unchanged and remains pinned by the existing hand-written-header tests. ## Testing - Unit round-trips: exact with zero shift, shifted read, sentinel passthrough, saturation, Local→UTC normalization. - End-to-end through the real worker/segment-log pipeline: an anchored timestamp re-bases across a simulated two-hour downtime via the idx v5 header. - Full suites green: Server.Tests 835/835, UOContent.Tests 708/708 (including the existing v4/v3 idx loading tests).
62 lines
2.3 KiB
C#
62 lines
2.3 KiB
C#
/*************************************************************************
|
|
* ModernUO *
|
|
* Copyright 2019-2026 - ModernUO Development Team *
|
|
* Email: hi@modernuo.com *
|
|
* File: IGenericWriter.cs *
|
|
* *
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
* it under the terms of the GNU General Public License as published by *
|
|
* the Free Software Foundation, either version 3 of the License, or *
|
|
* (at your option) any later version. *
|
|
* *
|
|
* You should have received a copy of the GNU General Public License *
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
|
*************************************************************************/
|
|
|
|
using System;
|
|
using System.Collections;
|
|
using System.IO;
|
|
using System.Net;
|
|
|
|
namespace Server;
|
|
|
|
public interface IGenericWriter
|
|
{
|
|
long Position { get; }
|
|
void Write(string value);
|
|
void Write(long value);
|
|
void Write(ulong value);
|
|
void Write(int value);
|
|
void Write(uint value);
|
|
void Write(short value);
|
|
void Write(ushort value);
|
|
void Write(double value);
|
|
void Write(float value);
|
|
void Write(byte value);
|
|
void Write(sbyte value);
|
|
void Write(bool value);
|
|
void Write(Serial serial);
|
|
void Write(Type type);
|
|
void Write(decimal value);
|
|
void WriteEncodedInt(int value);
|
|
void Write(DateTime value);
|
|
void WriteDeltaTime(DateTime value);
|
|
void WriteAnchoredTime(DateTime value);
|
|
void Write(IPAddress value);
|
|
void Write(TimeSpan value);
|
|
void Write(Point3D value);
|
|
void Write(Point2D value);
|
|
void Write(Rectangle2D value);
|
|
void Write(Rectangle3D value);
|
|
void Write(Map value);
|
|
void Write(Race value);
|
|
void Write(byte[] bytes);
|
|
void Write(byte[] bytes, int offset, int count);
|
|
void Write(ReadOnlySpan<byte> bytes);
|
|
void WriteEnum<T>(T value) where T : unmanaged, Enum;
|
|
void Write(Guid guid);
|
|
void Write(BitArray bitArray);
|
|
void Write(TextDefinition def);
|
|
|
|
long Seek(long offset, SeekOrigin origin);
|
|
}
|