ModernUO/Projects
Kamron Batman 79df316163
refactor(pathing): simplify StepCacheFile.Write and consolidate the format tests
SaveToFile walked _keysList twice - once to count the map's chunks, then again
through a ChunkEnumerator closure to emit them - because Write needed the count up
front to size its index array. It now collects the map's chunks into a
PooledRefList in one pass and hands Write a span, so the count is just span.Length.

That deletes the ChunkEnumerator delegate, the closure over the list enumerator,
and both InvalidOperationException throws, which existed only to police the
delegate's "yield exactly chunkCount chunks" contract - a contract a span makes
unrepresentable.

Write now patches the header's IndexOffset by seeking back to it rather than
reaching into the writer's live buffer with BinaryPrimitives. This also removes the
IndexOffsetFieldPosition constant, which hard-coded the field's byte offset and had
to be kept in sync with the header layout by hand.

Tests: StepCacheFileV6/V7/V8Tests were named for the format version that introduced
each transform, and the format is now v9 - so all three names described formats the
loader rejects outright. Each file also carried its own copy of the chunk builders,
the round-trip plumbing, and the assertion helper, plus a near-identical
"an older version is rejected" test whose comment cited a MinSupportedVersion that
had since moved.

They are now one StepCacheFileFormatTests named for the behavior it covers -
predictive-Z elision, compression, the compact index - with shared builders, a
single AssertIdentical that checks the swim and strata trailers too (the old
AssertBaseEqual silently skipped both), and the three rejection tests folded into
one theory that also covers a future version. Added a zero-chunk case, which the
old delegate-based writer had no coverage for.

Verified non-vacuous: injecting an off-by-one into the IndexOffset patch fails 15
of the 123 tests.

Also reattaches a doc comment in StepCacheFileTests that had drifted off
LazyReaderHit_BypassesMissTrackerOnFirstTouch and stacked onto the test above it,
and drops its reference to the long-gone "v3 file format".

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-12 19:40:37 -07:00
..
Application feat(build-tool): add application icon and refresh MUO.ico (#2487) 2026-06-14 11:59:54 -07:00
BuildTool fix: Bumps dependencies. Adds Server 2012/2016 support. (#2509) 2026-07-02 19:29:34 -07:00
Logger fix: Fixes publishing with build tool (#2398) 2026-04-04 00:35:39 -07:00
Server fix: Optimizes outgoing packet encoding. (#2522) 2026-07-12 18:37:14 -07:00
Server.Tests feat(opl): OplTextBlock multi-line tooltip builder + AddChunked (#2507) 2026-07-02 19:41:36 -07:00
UOContent refactor(pathing): simplify StepCacheFile.Write and consolidate the format tests 2026-07-12 19:40:37 -07:00
UOContent.Tests refactor(pathing): simplify StepCacheFile.Write and consolidate the format tests 2026-07-12 19:40:37 -07:00