fix(chargen): Campaign CC CC6b-MOUNT review fix round — F1-F13

Fixes every finding from the dual-lens review of 34c6fceab0 (architectural
PASS-with-items, retail-fidelity FAIL). Re-derived every decomp citation
against docs/research/named-retail/acclient_2013_pseudo_c.txt directly
rather than trusting the reviewer's transcription.

Wrap/normalize semantics (F1): CycleIndex's decrement-from-Unset landed on
0; the decomp's shared decrement tail (label_47f065/label_47f6d9, the same
switch the headgear ring was ported from) computes new=cur-1=-2 on the raw
signed int32, which wraps to count-1 — matching headgear's own ring shape.
Also ports the spin body-click normalize-and-write-back retail's cases
0xa5-0xae all share (NormalizeChoiceOnSelect), which acdream had dropped
entirely. Flips the one test that pinned the wrong expectation and adds
select-zone coverage no prior test isolated.

Heritage gate (F3): Update's Gearknight/Olthoi/OlthoiAcid branches reset
SetChoice(FACE)/SetSelection(HAIR) unconditionally, not only when Clothes
was showing — a conditional gate stranded Nose/Mouth as the current part
under a Face-tab session.

Doc corrections propagated everywhere they repeated (F4, F5, F6, plus the
plan doc's own CC6b-MOUNT ledger row for F1/F3): the gmBarberUI heading
citation conflated PostInit with InitializePage; Random's Appearance
disable was mislabeled a placeholder when it's really AP-212's unported
RandomizeAppearance/RandomizeClothing gap; the master-page doc still called
the Appearance page content-inert after this campaign made it real.

Visual substitutions widened (F2): AP-215 named only two of the Appearance
page's swatch/spin substitutions. Ports the two cheap ones directly —
current-part highlight via SetSelection's SetState(1)/SetState(6), routed
through the existing UiButtonStateMachine.Normal/Highlight ids and
IUiDatStateful.TrySetRetailState seam (installed-DAT-confirmed
ToggleBehavior=true on all nine spins); the shade scrollbar's SetVisible(0)
for Eyes vs acdream's Enabled=false. Files the other five (DoColorSpots,
the inert GradCircle, spin-caption/heritage-caption loss, the Skin-spin
MoveTo reposition, the Gearknight-boundary randomize calls) as new register
rows AP-216..AP-220 and corrects the plan doc's false claim that AP-215
already named the GradCircle.

Unlocked DAT read (F7, BLOCKER): ChargenPreviewController.Rebuild called
ChargenAppearanceFactory.TryCompose outside _datLock while the very next
line correctly locked TryBuildAnimated — CC6a's own F4 class of bug,
reintroduced at this catalog's first production call site. Wrapped in the
same lock; documented the invariant on ChargenAppearanceCatalog itself.

One-shot preview mount (F8): LivePresentationComposition reads
ChargenPreviewViewportWidget once, but its underlying mount
(CharacterCreationUiMountCoordinator) is explicitly retryable while this
GPU-resource composition pass is not — unlike PaperdollViewportWidget,
which IS eager/non-retryable, so the "mirrors Paperdoll" doc claim was
false. Retrofitting cross-frame retry here would mean restructuring this
composition's one-shot contract for every private viewport (paperdoll,
creature appraisal) and FrameRootComposition's fixed frame-group array —
out of this round's blast radius. Corrected the doc and made the failure
loud (a diagnostic log) instead of silent.

Dispose leak (F9): ChargenPreviewController.Dispose left the preview
WorldEntity referenced by the leased renderer until the renderer's own,
later disposal. Releases it on its own teardown now.

Test-quality items (F10, F11, F13): pinned the spin arrow widths
(47px, both arrows) the 174 zone boundary is derived from, plus a
controller test for the previously-uncovered select zone. Measured the
shade scrollbar's authored orientation instead of assuming it — it is
VERTICAL (33x85) — which is a real production bug: UiScrollbar only routed
scalar-mode mouse events when Horizontal was true, so the shade control
never fired in production. Added OnVerticalScalarEvent/DrawVerticalScalar
mirroring the existing horizontal scalar path. Converted
ChargenPreviewControllerTests from silent-pass [Fact] to the shared
InstalledDatFactAttribute skip-reporting pattern.

Adjudication (F12): AD-101's retirement leaves TryBeginFinish's four local
refusals (NoName/AttributeCreditsUnspent/AlreadyPending/RosterFull) with no
heritage/gender gate — currently latent since Finish stays hard-disabled
this round. Amended the campaign plan's CC5 slice scope to require BOTH a
heritage/gender refusal AND a real RandomizeCharacter port before the
connected user gate opens Finish; noted the interaction on AP-214's own
register row. No CC5 implementation in this commit.

Gates: dotnet build -c Release green across the full solution. App suite
(Release, ACDREAM_PROBE_LIVE_MOUNT=1) 5223/3 skips, Runtime suite
1713/0 — both clean across repeated runs. A full-solution run surfaced
three pre-existing, previously-documented flakes unrelated to this change
(Streaming.LandblockBuildFactoryTests/LandblockPresentationPipelineTests
#402, Core.Net.Tests.NakEmissionTests loss soak) — each confirmed passing
in isolation, consistent with their known full-suite-parallelism-timing
history; none touch any file this commit changes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-08-15 22:19:02 +02:00
parent 34c6fceab0
commit d2a71152d2
14 changed files with 571 additions and 54 deletions

View file

@ -1,5 +1,6 @@
using System.Numerics;
using AcDream.App.Rendering;
using AcDream.App.Tests.UI.Layout; // InstalledDatFactAttribute (fix round F13)
using AcDream.Content;
using AcDream.Content.CharGen;
using AcDream.Content.Vfx;
@ -22,6 +23,18 @@ namespace AcDream.App.Tests.Rendering;
/// REAL dat-backed <see cref="ChargenOptions"/>/<see cref="ChargenAppearanceCatalog"/>
/// so <c>ChargenAppearanceFactory.TryCompose</c> and
/// <c>ChargenPreviewEntityBuilder.TryBuildAnimated</c> actually run.
///
/// <para>
/// Fix round F13: every case uses
/// <see cref="InstalledDatFactAttribute"/> (shared with
/// <c>CharacterCreationLiveDatTests</c>/<c>CharacterManagementLiveDatTests</c>)
/// instead of plain <c>[Fact]</c>. Before this fix, a bare <c>[Fact]</c> plus
/// <see cref="TryOpen"/>'s own <c>if (!TryOpen(...)) return;</c> guard made
/// all six cases pass SILENTLY with zero assertions run whenever
/// <c>ACDREAM_DAT_DIR</c> was unavailable — indistinguishable in the test
/// runner's summary from an actual passing run. The attribute now reports
/// those runs as Skipped so the counts show "ran" separately from "no-op'd".
/// </para>
/// </summary>
public sealed class ChargenPreviewControllerTests
{
@ -31,7 +44,7 @@ public sealed class ChargenPreviewControllerTests
private const uint AluvianId = 1u;
private const uint GearknightId = 6u;
[Fact]
[InstalledDatFact]
public void Rebuild_SameSelectionTwice_IsANoOpSecondTime()
{
if (!TryOpen(out DatCollection? dats, out DatCollectionAdapter? adapter))
@ -54,7 +67,7 @@ public sealed class ChargenPreviewControllerTests
}
}
[Fact]
[InstalledDatFact]
public void Rebuild_HeritageChange_ResetsCameraToTheNewHeritagesDefaultEye()
{
if (!TryOpen(out DatCollection? dats, out DatCollectionAdapter? adapter))
@ -101,7 +114,7 @@ public sealed class ChargenPreviewControllerTests
/// changes ONLY the appearance selection (same heritage, same gender)
/// must NOT snap the camera back to the heritage default.
/// </summary>
[Fact]
[InstalledDatFact]
public void Rebuild_AppearanceOnlyChange_LeavesTheCameraUntouched()
{
if (!TryOpen(out DatCollection? dats, out DatCollectionAdapter? adapter))
@ -129,7 +142,7 @@ public sealed class ChargenPreviewControllerTests
}
}
[Fact]
[InstalledDatFact]
public void Rebuild_PreservesZoomState_AcrossAnAppearanceOnlyChange()
{
if (!TryOpen(out DatCollection? dats, out DatCollectionAdapter? adapter))
@ -160,7 +173,7 @@ public sealed class ChargenPreviewControllerTests
}
}
[Fact]
[InstalledDatFact]
public void Rebuild_ThenRender_SeedsTheEntityHeadingToTheRetailDefault180Degrees()
{
if (!TryOpen(out DatCollection? dats, out DatCollectionAdapter? adapter))
@ -191,7 +204,7 @@ public sealed class ChargenPreviewControllerTests
}
}
[Fact]
[InstalledDatFact]
public void Render_WhilePageInvisible_SkipsRenderAndTexturePublication()
{
if (!TryOpen(out DatCollection? dats, out DatCollectionAdapter? adapter))
@ -230,6 +243,14 @@ public sealed class ChargenPreviewControllerTests
private static (ChargenOptions, ChargenAppearanceCatalog) LoadFixture(IDatReaderWriter dats) =>
(ChargenTableReader.Load(dats), new ChargenAppearanceCatalog(dats));
/// <summary>
/// Fix round F13: <see cref="InstalledDatFactAttribute"/> already gates
/// every case above this call, so <c>datDir is null</c> should not be
/// reachable in practice once a case actually runs — this stays as
/// defense-in-depth (a DAT directory that exists but a corrupt/renamed
/// <c>client_portal.dat</c> the attribute's own lighter check missed)
/// rather than a silent no-assertions pass.
/// </summary>
private bool TryOpen(out DatCollection? dats, out DatCollectionAdapter? adapter)
{
string? datDir = CornerFloodReplayTests.ResolveDatDir();

View file

@ -359,7 +359,17 @@ public sealed class CharacterCreationLiveDatTests
CharacterCreationAppearancePage.FootwearSpinId,
})
{
AssertButton(appearanceRoot, spinId);
UiButton spin = AssertButton(appearanceRoot, spinId);
// Fix round F2 item 2: the current-part highlight
// (TrySetRetailState(Normal/Highlight)) only has a visible
// effect through UiButton's ToggleBehavior branch when the
// authored spin actually sets DAT property 0x0B — measured
// (not assumed, matching this file's own discipline for the
// arrow geometry above) True for all nine spins against the
// installed EoR dat. Pinned so a future DAT revision that
// drops it shows up here instead of as a silently-dead
// highlight.
Assert.True(spin.ToggleBehavior, $"spin 0x{spinId:X8} must author ToggleBehavior for the current-part highlight to work.");
}
// Every color-wheel-family id resolves through EXISTING
@ -367,8 +377,20 @@ public sealed class CharacterCreationLiveDatTests
// Type-3 fallback) — the risk-item-4 scouting result, pinned.
foreach (uint swatchId in CharacterCreationAppearancePage.SwatchIds)
AssertButton(appearanceRoot, swatchId);
Assert.IsType<UiScrollbar>(
UiScrollbar shadeScroll = Assert.IsType<UiScrollbar>(
UiElement.FindDescendant(appearanceRoot, CharacterCreationAppearancePage.ShadeScrollId));
// Fix round F11: measured (not assumed) against the installed EoR
// dat — the shade scrollbar (0x10000321) is authored VERTICAL
// (33x85, taller than wide). Before this fix, UiScrollbar.OnEvent
// only routed to ScalarChanged when Horizontal was true, so mouse
// input on this control never reached SetShadeFromScalar in
// production. Pinned so a future DAT revision that flips this
// orientation is caught here rather than silently reintroducing the
// dead-input bug (UiScrollbar's OnVerticalScalarEvent handles this
// orientation now, but ONLY this orientation gets exercised in
// production).
Assert.False(shadeScroll.Horizontal);
Assert.True(shadeScroll.Height > shadeScroll.Width);
Assert.IsType<UiDatElement>(
UiElement.FindDescendant(appearanceRoot, CharacterCreationAppearancePage.GradCircleId));
@ -426,6 +448,15 @@ public sealed class CharacterCreationLiveDatTests
Assert.NotNull(increment);
Assert.Equal(80f, decrement!.X);
Assert.Equal(127f, increment!.X);
// Fix round F10: the arrow WIDTHS are what actually derive
// CharacterCreationAppearancePage.IncrementZoneEnd (174 =
// IncrementZoneStart 127 + this measured 47px width) — X alone
// pins the LEFT edge of each zone, not where the increment zone
// ends and the select-as-current-part body zone begins. Measured
// against the installed EoR dat: both arrows are 47px wide,
// uniformly, across all nine spins.
Assert.Equal(47f, decrement.Width);
Assert.Equal(47f, increment.Width);
}
}
@ -457,7 +488,7 @@ public sealed class CharacterCreationLiveDatTests
private static void AssertButton(ImportedLayout layout, uint elementId) =>
Assert.IsType<UiButton>(layout.FindElement(elementId));
private static void AssertButton(UiElement root, uint elementId) =>
private static UiButton AssertButton(UiElement root, uint elementId) =>
Assert.IsType<UiButton>(UiElement.FindDescendant(root, elementId));
private static ImportedLayout BuildSelected(

View file

@ -527,21 +527,88 @@ public sealed class CharacterCreationUiControllerTests
Assert.Equal(0u, environment.Runtime.LastAppearanceIndex);
}
/// <summary>
/// Fix round F1: this test previously asserted index 0 here, pinning a
/// doc claim ("no decomp-observable Unset-cycling case") the decomp
/// refutes. Hair's own decrement case
/// (<c>gmCGAppearancePage::ListenToElementMessage @0x0047f465-0x0047f086</c>,
/// the same shared tail the headgear ring reuses at
/// <c>label_47f065</c>/<c>label_47f6d9</c>) computes
/// <c>new = cur - 1</c> on the raw signed int32 (Unset = -1), giving
/// <c>new = -2</c>; since <c>-2 &lt; 0</c> it wraps to <c>count - 1</c>,
/// NOT 0 — see <see cref="CharacterCreationAppearancePage.CycleIndex"/>'s
/// own corrected doc. The fixture's Hair style count is 3
/// (<see cref="EnvironmentHarness.BuildOptions"/>), so the expected
/// landing index is 2.
/// </summary>
[Fact]
public void AppearanceSpin_DecrementZoneClick_FromUnset_StartsAtStyleZero()
public void AppearanceSpin_DecrementZoneClick_FromUnset_WrapsToLastStyle()
{
using var environment = new EnvironmentHarness();
environment.Controller.Open();
SelectAluvianMale(environment);
// Non-headgear spins have no decomp-observable Unset-cycling case
// (retail always has a real 0-based index by the time the user can
// click — CycleIndex's own citation) — a first click from Unset in
// EITHER direction just starts cycling at style 0, not a ring.
environment.Button(CharacterCreationAppearancePage.HairSpinId).OnClickAt!(100, 10);
Assert.Equal(ChargenAppearanceSlot.HairStyle, environment.Runtime.LastAppearanceSlot);
Assert.Equal(2u, environment.Runtime.LastAppearanceIndex);
}
/// <summary>
/// Fix round F10: pins the SELECT zone — x=[174,200), right of the
/// increment arrow's own x=[127,174) (live-DAT-measured, both arrows
/// 47px wide — <c>CharacterCreationLiveDatTests</c>) — as a body click
/// that selects the part WITHOUT invoking another style cycle, once the
/// part already holds a real (non-Unset) index. Distinguishes the third
/// <c>OnClickAt</c> zone from the two arrow-zone tests above, which no
/// prior test isolated.
/// </summary>
[Fact]
public void AppearanceSpin_SelectZoneClick_SelectsPartWithoutChangingIndex()
{
using var environment = new EnvironmentHarness();
environment.Controller.Open();
SelectAluvianMale(environment);
// Establish a real Hair index first (increment zone, x=150).
environment.Button(CharacterCreationAppearancePage.HairSpinId).OnClickAt!(150, 10);
Assert.Equal(0u, environment.Runtime.LastAppearanceIndex);
int callsAfterCycle = environment.Runtime.AppearanceIndexCallCount;
// x=180 is inside [174,200) — past the increment arrow's own zone,
// still inside the 200px-wide spin — the spin's own BODY, not
// either arrow.
environment.Button(CharacterCreationAppearancePage.HairSpinId).OnClickAt!(180, 10);
// Already in [0,count) — NormalizeChoiceOnSelect (F1) is a no-op,
// so the select zone must not re-invoke SetAppearanceIndex.
Assert.Equal(callsAfterCycle, environment.Runtime.AppearanceIndexCallCount);
Assert.Equal(ChargenAppearanceSlot.HairStyle, environment.Runtime.LastAppearanceSlot);
Assert.Equal(0u, environment.Runtime.LastAppearanceIndex);
}
/// <summary>
/// Fix round F1: pins the body-click normalize-and-write-back
/// (<see cref="CharacterCreationAppearancePage"/>'s own
/// <c>NormalizeChoiceOnSelect</c> doc) for the case that's actually
/// reachable in acdream — a part still Unset (AP-214 honest-blank open)
/// gets clicked in its SELECT zone (not an arrow) — wraps to
/// <c>count-1</c> and writes it back, exactly like a decrement click
/// would, even though no arrow was pressed.
/// </summary>
[Fact]
public void AppearanceSpin_SelectZoneClick_FromUnset_NormalizesToLastStyle()
{
using var environment = new EnvironmentHarness();
environment.Controller.Open();
SelectAluvianMale(environment);
// Hair starts Unset (AP-214 honest-blank). x=180 is the select
// zone, not either arrow.
environment.Button(CharacterCreationAppearancePage.HairSpinId).OnClickAt!(180, 10);
Assert.Equal(ChargenAppearanceSlot.HairStyle, environment.Runtime.LastAppearanceSlot);
Assert.Equal(2u, environment.Runtime.LastAppearanceIndex); // count-1, fixture has 3 hair styles.
}
/// <summary>CharGenState::SetHeadgearStyle's decomp-derived
@ -576,7 +643,12 @@ public sealed class CharacterCreationUiControllerTests
[InlineData(1u, -1, 3, false, 0u)]
[InlineData(0u, -1, 3, false, 2u)] // plain wrap backward past the start.
[InlineData(RuntimeCharacterCreationAppearance.Unset, +1, 3, false, 0u)]
[InlineData(RuntimeCharacterCreationAppearance.Unset, -1, 3, false, 0u)]
// Fix round F1: decrement-from-Unset wraps to count-1 (2), not 0 — the
// decomp's shared decrement tail (label_47f065/label_47f6d9) computes
// new = cur - 1 = -2 on the raw signed int32, which is < 0, so it wraps
// to count-1 exactly like headgear's own ring does for its non-Unset
// range. See CycleIndex's own corrected doc.
[InlineData(RuntimeCharacterCreationAppearance.Unset, -1, 3, false, 2u)]
[InlineData(0u, -1, 3, true, RuntimeCharacterCreationAppearance.Unset)] // headgear ring: 0 -> Unset.
[InlineData(RuntimeCharacterCreationAppearance.Unset, +1, 3, true, 0u)] // headgear ring: Unset -> 0.
[InlineData(2u, +1, 3, true, RuntimeCharacterCreationAppearance.Unset)] // headgear ring: last -> Unset.

View file

@ -103,6 +103,43 @@ public class UiScrollbarTests
Assert.True(bar.OnEvent(new UiEvent(0u, bar, UiEventType.MouseUp, Data1: 45)));
}
/// <summary>
/// Fix round F11 (Campaign CC CC6b-MOUNT review): retail's chargen shade
/// scrollbar (<c>0x10000321</c>) is authored VERTICAL (measured 33x85
/// against the installed dat — see
/// <c>CharacterCreationLiveDatTests.AppearancePage_HasGenderChoiceSpinsSwatchesShadeAndViewport</c>),
/// but before this fix <c>UiScrollbar.OnEvent</c> only routed to
/// <c>ScalarChanged</c> when <c>Horizontal</c> was true — a vertical
/// scalar bar's clicks fell through to the Model-mode branch, which
/// returns false with no <see cref="UiScrollbar.Model"/> set, so the
/// shade control never fired in production. Mirrors
/// <see cref="HorizontalScalar_clickAndDrag_updatesNormalizedValue"/>
/// exactly, transposed onto Y/Height/Data2.
/// </summary>
[Fact]
public void VerticalScalar_clickAndDrag_updatesNormalizedValue()
{
float value = 1f;
var bar = new UiScrollbar
{
Width = 14f,
Height = 90f,
Horizontal = false,
ScalarChanged = next => value = next,
};
bar.SetScalarPosition(1f);
Assert.True(bar.OnEvent(new UiEvent(0u, bar, UiEventType.MouseDown, Data2: 8)));
Assert.Equal(0f, value, 3);
Assert.Equal(0f, bar.ScalarPosition, 3);
Assert.True(bar.OnEvent(new UiEvent(0u, bar, UiEventType.MouseMove, Data2: 45)));
Assert.Equal(0.5f, value, 3);
Assert.Equal(0.5f, bar.ScalarPosition, 3);
Assert.True(bar.OnEvent(new UiEvent(0u, bar, UiEventType.MouseUp, Data2: 45)));
}
// ── OP5 review fix S1: the drag-end seam (IsDragging / DragCompleted) ────
[Fact]