ModernUO/Projects/Server.Tests/Tests
Kamron Batman 5570537aa0
fix: anchored times shift only while still running at save start (#2730)
Follow-up to #2729.

## Problem

At load, `ReadAnchoredTime` shifted **every** anchored value forward by the downtime, including values that were already in the past when the save started. That caused two problems.

**An expired deadline came back.** A deadline that passed 5 minutes before a 30-minute outage loaded 25 minutes in the future. For example:
- `Sheep.NextWoolTime`: a sheep that was ready to shear stopped being ready.
- `PlayerVendor.NextPayTime`: an overdue payment was pushed back.
- `BaseCreature.SummonEnd`, the spell fields' `End`, `TransientItem.Expiration`, and the ChampionSpawn times could move the same way.

**Records were rewritten for nothing.** The first save after every restart rewrote:
- stamps of things that had already happened: VirtueContext's `LastHonorUse`, `LastSacrificeGain`, the four `Last*Loss` stamps, and `Corpse.TimeOfDeath`
- every deadline that had expired long ago.

## Change

- **`IGenericReader.AnchoredTimeOrigin`** is the loaded save's start time.
  - `GenericEntityPersistence` and `GenericPersistence` set it from `World.LoadedSaveStartTime`.
  - `BufferReader`, `UnmanagedDataReader` and `BinaryFileReader` expose it.
- **`ReadAnchoredTime` returns any value at or before the origin exactly as saved.**
  - A deadline still running at save start is shifted as before and keeps its remaining time.
  - Readers without an origin keep the old behaviour.
- **This covers every anchored field, including generated ones.** Generated `[AnchoredDateTime]` fields call `reader.ReadAnchoredTime()`, so the one change covers all 26 generated fields as well as the manual reads. `[DeserializeTimer]` only restores timers that were running at save time, so it is unaffected.
- **The `[AnchoredDateTime]` section of `dev-docs/serialization.md` and the `WriteAnchoredTime` doc comment describe the new rule.**

## Behaviour change

Downtime now counts toward windows measured from a past stamp:

| Window | Length |
|---|---|
| Honor use | 5 minutes |
| Sacrifice gain | 1 day |
| Virtue atrophy | 7 days |
| Instanced corpse looting | 3 minutes |

A 30-minute outage makes a 7-day atrophy fire about 0.3% sooner. No format change.

## Tests

New tests in `AnchoredTimeTests`:
- A deadline running at save start keeps its remaining time.
- A deadline that passed before save start stays passed.
- A past stamp is not shifted.
- A value exactly at save start is not shifted.

`Server.Tests`: 845 passed. `UOContent.Tests`: 1140 passed.
2026-10-25 16:44:33 -07:00
..
Buffers test: remove trivial, duplicate and content-value tests (#2721) 2026-10-18 20:08:19 -07:00
Client test: fix shared state, CI-vacuous tests and harness duplication (#2722) 2026-10-18 20:11:33 -07:00
Collections test: remove trivial, duplicate and content-value tests (#2721) 2026-10-18 20:08:19 -07:00
Console test: fix shared state, CI-vacuous tests and harness duplication (#2722) 2026-10-18 20:11:33 -07:00
Geometry test: fix shared state, CI-vacuous tests and harness duplication (#2722) 2026-10-18 20:11:33 -07:00
Items test: fix shared state, CI-vacuous tests and harness duplication (#2722) 2026-10-18 20:11:33 -07:00
Json test: remove trivial, duplicate and content-value tests (#2721) 2026-10-18 20:08:19 -07:00
Localization test: fix shared state, CI-vacuous tests and harness duplication (#2722) 2026-10-18 20:11:33 -07:00
Maps test: run tile-dependent tests on synthetic terrain instead of client files (#2725) 2026-10-18 22:07:40 -07:00
Mobiles perf: keep damage entries in an inline intrusive list (#2605) 2026-09-01 23:25:14 -07:00
Network test: run tile-dependent tests on synthetic terrain instead of client files (#2725) 2026-10-18 22:07:40 -07:00
PropertyList test: fix shared state, CI-vacuous tests and harness duplication (#2722) 2026-10-18 20:11:33 -07:00
Serialization fix: anchored times shift only while still running at save start (#2730) 2026-10-25 16:44:33 -07:00
Terrain test: run tile-dependent tests on synthetic terrain instead of client files (#2725) 2026-10-18 22:07:40 -07:00
Text chore: Code Cleanup (#1239) 2022-11-10 22:49:25 -08:00
Timer fix: ClearAllTimers stops every timer in a slot, not just the first (#2723) 2026-10-18 20:10:19 -07:00
Utility test: remove trivial, duplicate and content-value tests (#2721) 2026-10-18 20:08:19 -07:00
World test: fix shared state, CI-vacuous tests and harness duplication (#2722) 2026-10-18 20:11:33 -07:00
SerialTests.cs fix: Adds ISpanFormattable support to Serial (#1065) 2022-06-14 18:39:46 -07:00