## Summary Adopts ModernUO.Serialization 4.0.0 across the engine. Three commits, reviewable independently: 1. **Package + tool bump to 4.0.0** (`Server.csproj`, `UOContent.csproj`, `dotnet-tools.json`). 2. **Timers → `[DeserializeTimer]`** — the 8 drifting timers (BaseLight, TreasureMapChest, MarkContainer, FillableContainer, DeathRobe, DecayedCorpse, Corpse, BaseEscortable) now store their next tick as **anchored time**: server downtime no longer consumes the remaining delay, and idle-world saves are byte-stable. This changes their wire format, so each class bumps its serialization version with a `MigrateFrom` that replays the old delta-time read through the migration schema (the new `vN.json` files carry `@AnchoredTimer`; the old ones keep `@TimerDrift`, which the generator reads forever). The 2 wall-clock timers (Aquarium, FountainOfLife) keep their exact format via `wallClock: true` — no bump. Restart methods drop their `TimeSpan.MinValue` sentinel checks: v4 invokes them **only when a timer was actually running at save**. 3. **Linkage → field-side declarations** — 175 conversions across 25 files: `[SerializableFieldSaveFlag(order)]`/`[SerializableFieldDefault(order)]` become `[SaveFlag(nameof(...), nameof(...))]` on the field, and `[SerializableFieldChanged(order)]` becomes the `fieldChanged:` argument of `[SerializableField]`. **Wire-neutral: zero migration schemas changed.** ## Verification - Solution builds with **0 errors, 0 warnings**; all three 4.0.0 packages verified indexed on nuget.org (no local feed needed). - **835 + 708 tests green.** - Generated output inspected: old-version content structs replay `ReadDeltaTime` (e.g. `V3Content.DecayTimerNext = reader.ReadDeltaTime()`), current versions write/read anchored time with the gated restart, and the wall-clock classes emit byte-identical `Write`/`ReadDateTime` framing. - Schema tool run is committed (CI's `git diff --exit-code` schema check passes): exactly the 8 expected new `vN.json` files, nothing else touched. - The conversion was scripted with a class-scoped resolver (order → same-class `[SerializableField(order)]`/`[SerializableProperty(order)]`); it planned 175/175 with zero ambiguities before applying. ## Notes - New `MigrateFrom`s use the content structs' provided `XxxDelay` property, matching the pre-existing idiom in Corpse's and TreasureMapChest's older migrations. - Follow-up candidate (separate PR, wire-neutral, any time): fold the ~150 eligible hand-written `[SerializableProperty]` setters (clamps, post-change side effects) down to `[SerializableField]` with `allowFieldChange`/`fieldChanged` hooks.
238 lines
5.9 KiB
C#
238 lines
5.9 KiB
C#
using System;
|
|
using ModernUO.Serialization;
|
|
|
|
namespace Server.Items;
|
|
|
|
[SerializationGenerator(1, false)]
|
|
public partial class MarkContainer : LockableContainer
|
|
{
|
|
[SerializableField(1, getter: "private", setter: "private")]
|
|
[DeserializeTimer(nameof(DeserializeRelockTimer))]
|
|
private InternalTimer _relockTimer;
|
|
|
|
private void DeserializeRelockTimer(TimeSpan delay)
|
|
{
|
|
if (!Locked && _autoLock)
|
|
{
|
|
_relockTimer = new InternalTimer(this, delay);
|
|
}
|
|
}
|
|
|
|
private void MigrateFrom(V0Content content)
|
|
{
|
|
_autoLock = content.AutoLock;
|
|
_targetMap = content.TargetMap;
|
|
_target = content.Target;
|
|
_description = content.Description;
|
|
|
|
if (content.RelockTimerDelay != TimeSpan.MinValue)
|
|
{
|
|
DeserializeRelockTimer(content.RelockTimerDelay);
|
|
}
|
|
}
|
|
|
|
[SerializableField(2)]
|
|
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
|
private Map _targetMap;
|
|
|
|
[SerializableField(3)]
|
|
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
|
private Point3D _target;
|
|
|
|
[SerializableField(4)]
|
|
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
|
private string _description;
|
|
|
|
[Constructible]
|
|
public MarkContainer(bool bone = false, bool locked = false) : base(bone ? 0xECA : 0xE79)
|
|
{
|
|
Movable = false;
|
|
|
|
if (bone)
|
|
{
|
|
Hue = 1102;
|
|
}
|
|
|
|
_autoLock = locked;
|
|
Locked = locked;
|
|
|
|
if (locked)
|
|
{
|
|
LockLevel = ILockpickable.MagicLock;
|
|
}
|
|
}
|
|
|
|
[SerializableProperty(0)]
|
|
[CommandProperty(AccessLevel.GameMaster)]
|
|
public bool AutoLock
|
|
{
|
|
get => _autoLock;
|
|
set
|
|
{
|
|
_autoLock = value;
|
|
|
|
if (!_autoLock)
|
|
{
|
|
StopTimer();
|
|
}
|
|
else if (!Locked)
|
|
{
|
|
_relockTimer ??= new InternalTimer(this);
|
|
}
|
|
}
|
|
}
|
|
|
|
[CommandProperty(AccessLevel.GameMaster)]
|
|
public bool Bone
|
|
{
|
|
get => ItemID == 0xECA;
|
|
set
|
|
{
|
|
ItemID = value ? 0xECA : 0xE79;
|
|
Hue = value ? 1102 : 0;
|
|
}
|
|
}
|
|
|
|
public override bool IsDecoContainer => false;
|
|
|
|
[CommandProperty(AccessLevel.GameMaster)]
|
|
public override bool Locked
|
|
{
|
|
get => base.Locked;
|
|
set
|
|
{
|
|
base.Locked = value;
|
|
|
|
if (_autoLock)
|
|
{
|
|
StopTimer();
|
|
|
|
if (!Locked)
|
|
{
|
|
_relockTimer = new InternalTimer(this);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
[CommandProperty(AccessLevel.GameMaster)]
|
|
public DateTime NextRelock => _relockTimer.Next;
|
|
|
|
public static void Configure()
|
|
{
|
|
CommandSystem.Register("SecretLocGen", AccessLevel.Developer, SecretLocGen_OnCommand);
|
|
}
|
|
|
|
[Usage("SecretLocGen")]
|
|
[Description("Generates mark containers to Malas secret locations.")]
|
|
public static void SecretLocGen_OnCommand(CommandEventArgs e)
|
|
{
|
|
CreateMalasPassage(951, 546, -70, 1006, 994, -70, false, false);
|
|
CreateMalasPassage(914, 192, -79, 1019, 1062, -70, false, false);
|
|
CreateMalasPassage(1614, 143, -90, 1214, 1313, -90, false, false);
|
|
CreateMalasPassage(2176, 324, -90, 1554, 172, -90, false, false);
|
|
CreateMalasPassage(864, 812, -90, 1061, 1161, -70, false, false);
|
|
CreateMalasPassage(1051, 1434, -85, 1076, 1244, -70, false, true);
|
|
CreateMalasPassage(1326, 523, -87, 1201, 1554, -70, false, false);
|
|
CreateMalasPassage(424, 189, -1, 2333, 1501, -90, true, false);
|
|
CreateMalasPassage(1313, 1115, -85, 1183, 462, -45, false, false);
|
|
|
|
e.Mobile.SendMessage("Secret mark containers have been created.");
|
|
}
|
|
|
|
private static bool FindMarkContainer(Point3D p, Map map)
|
|
{
|
|
foreach (var item in map.GetItemsAt<MarkContainer>(p))
|
|
{
|
|
if (item.Z == p.Z)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
private static void CreateMalasPassage(
|
|
int x, int y, int z, int xTarget, int yTarget, int zTarget, bool bone, bool locked
|
|
)
|
|
{
|
|
var location = new Point3D(x, y, z);
|
|
|
|
if (FindMarkContainer(location, Map.Malas))
|
|
{
|
|
return;
|
|
}
|
|
|
|
var cont = new MarkContainer(bone, locked)
|
|
{
|
|
TargetMap = Map.Malas,
|
|
Target = new Point3D(xTarget, yTarget, zTarget),
|
|
Description = "strange location"
|
|
};
|
|
|
|
cont.MoveToWorld(location, Map.Malas);
|
|
}
|
|
|
|
public void StopTimer()
|
|
{
|
|
_relockTimer?.Stop();
|
|
_relockTimer = null;
|
|
}
|
|
|
|
public void Mark(RecallRune rune)
|
|
{
|
|
if (_targetMap != null)
|
|
{
|
|
rune.Marked = true;
|
|
rune.TargetMap = _targetMap;
|
|
rune.Target = _target;
|
|
rune.Description = _description;
|
|
rune.House = null;
|
|
}
|
|
}
|
|
|
|
public override bool OnDragDrop(Mobile from, Item dropped)
|
|
{
|
|
if (dropped is RecallRune rune && base.OnDragDrop(from, dropped))
|
|
{
|
|
Mark(rune);
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public override bool OnDragDropInto(Mobile from, Item dropped, Point3D p)
|
|
{
|
|
if (dropped is RecallRune rune && base.OnDragDropInto(from, dropped, p))
|
|
{
|
|
Mark(rune);
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
private class InternalTimer : Timer
|
|
{
|
|
public InternalTimer(MarkContainer container) : this(container, TimeSpan.FromMinutes(5.0))
|
|
{
|
|
}
|
|
|
|
public InternalTimer(MarkContainer container, TimeSpan delay) : base(delay)
|
|
{
|
|
Container = container;
|
|
|
|
Start();
|
|
}
|
|
|
|
public MarkContainer Container { get; }
|
|
|
|
protected override void OnTick()
|
|
{
|
|
Container.Locked = true;
|
|
Container.LockLevel = ILockpickable.MagicLock;
|
|
}
|
|
}
|
|
}
|