The retail Options panel (Campaign OP) needs a Runtime-owned option map
covering all 53 PlayerOption ids and the real batched SetCharacterOptions
(0x01A1) blob before any UI can be built on top of it. Today's surface only
modeled 6 ListenTo*Chat ids and the 0x01A1 builder was a malformed 16-byte
stub (deleted at Campaign CH slice CH3, docs/research/2026-08-09-chat-side-
channels-vs-ace.md).
- CharacterOptionTable.cs: the ONE typed table, PlayerOption id (0x00..0x34)
-> (Options1/Options2 word, mask, IsAutoSave, ClientDefault), transcribed
from acclient.h's verbatim CharacterOption/CharacterOptions2/PlayerOption
enums and byte-verified against IsAutoSaveOption @0x0059A600 (the 21-id
auto-save table) and GetDefaultOptionValue @0x005D2A30 (the Defaults-
button table). Reconstructing CharacterOptions1/2 defaults from the
ClientDefault column independently reproduces 0x50C4A54A / 0x00008700,
cross-confirming the id-mask mapping. CharacterOptionId (SocialActions.cs)
widened from 6 to all 53 ids to match.
- RuntimeCharacterOptionsState: SetOptionBit now resolves through the full
table (was a 6-case switch). New TrySetOption is the ONE shared local-
write-then-send/dirty seam — mirrors CPlayerModule::OnChanged exactly:
write the bit locally first, then either send 0x0005 immediately (auto-
save ids) or MarkDirty for the batched blob, no-op on an unchanged value
(retail's own early-return) or an unmodeled id. New dirty model (IsDirty/
FirstDirtiedAt/MarkDirty/TryFlush/TryFlushIfAutoSaveDue) uses an injected
TimeProvider so it's fully unit-testable without a live clock.
- Both IRuntimeCharacterCommands.SetSingleOption adapters (Direct + Current)
now route through TrySetOption instead of duplicating the write; this
fixes the headless local-write gap the OP1 research flagged (the direct
adapter previously sent the wire message without writing the bit first,
same class of bug CH4 fixed for the graphical host). Both also reject an
id outside the table instead of silently accepting it. LiveSessionRuntime
Factory's SendSingleCharacterOption closure now delegates to the same
seam instead of duplicating write-then-send inline.
- New IRuntimeCharacterCommands.SaveOptions(generation) — the explicit
blob-flush verb (retail's SaveToServer(force: 0)) — wired end-to-end in
both adapters, including a new SaveCharacterOptionsRuntimeCmd on the
graphical router.
- SocialActions.BuildSetCharacterOptions + WorldSession.SendSetCharacterOptions:
the real PlayerModule::Pack body per the wire research's field-by-field
layout — header always 0x460 OR'd with 0x001/0x008 when shortcuts/desired
comps are non-empty, favorite spells always 8 lists, never sets 0x100 or
0x200. Echoes last-parsed shortcuts/favorites/desired-comps/spellbook
filters (via new CharacterOptionsBlobSource) instead of zeroing them.
Conformance: a hand-computed golden byte vector (not generated by the
builder under test — the CH3 builder died of tests that pinned a wrong
shape and looked green) plus a round-trip through PlayerDescriptionParser.
Contract deviation: the 480 s auto-save timer and the flush-before-logout
trigger are implemented as fully-tested pure state-machine logic
(TryFlushIfAutoSaveDue) but are NOT wired into either host's live per-frame
loop or graceful-shutdown sequence in this slice — only the explicit
SaveOptions verb is production-wired. Wiring the timer touches App's
UpdateFrameOrchestrator graph and Headless's tick loop (outside this
slice's Runtime/wire-layer scope); wiring logout risks the already-fragile
graceful-shutdown sequence CLAUDE.md flags. Filed as TS-71 per the plan's
own escape valve ("target: not deferred" with a register row if deferred).
Also filed: AP-193 (the 0x34 HearPKDeathMessages id/mask is ACE-sourced,
unverifiable against the 2013 binary) and AP-194 (GetDefaultOptionValue's
table disagrees with the constructor default for ConfirmVolatileRareUse/
ShowHelm/ShowCloak — retail's own quirk, reproduced not fixed).
Tests: table completeness x53, auto-save/client-default split pinned
id-by-id against the byte-verified tables, unknown/reserved-id rejection
(0x35/0x36 landmines), local-write-then-send on both adapters + the router,
the dirty/flush state machine, SaveOptions, and the wire golden vector +
PlayerDescriptionParser round-trip. Full Release suite: 12,745 passed / 4
skipped / 0 failed (baseline 12,611/4/0 — slice adds 134 passing tests,
zero regressions).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
188 lines
7.4 KiB
C#
188 lines
7.4 KiB
C#
using AcDream.Core.Net.Messages;
|
|
using AcDream.Runtime.Gameplay;
|
|
|
|
namespace AcDream.Runtime.Tests.Gameplay;
|
|
|
|
/// <summary>
|
|
/// Campaign OP slice OP1 (2026-08-10) conformance for
|
|
/// <see cref="CharacterOptionTable"/> — table completeness across the
|
|
/// complete <c>0x00..0x34</c> id space, the auto-save split pinned
|
|
/// id-by-id against
|
|
/// docs/research/2026-08-10-set-character-options-wire.md §3.2's
|
|
/// byte-verified table, the client-Defaults split against §8.2's, and
|
|
/// unknown-id rejection (ACE throws on an unmodeled id — one must never
|
|
/// reach the wire, wire doc §5.4.2).
|
|
/// </summary>
|
|
public sealed class CharacterOptionTableTests
|
|
{
|
|
// wire research §3.2 — CPlayerModule::IsAutoSaveOption @0x0059A600,
|
|
// byte-verified 0x34-byte table at VA 0x0059A62C. 21 ids.
|
|
private static readonly CharacterOptionId[] AutoSaveIds =
|
|
[
|
|
CharacterOptionId.AutoRepeatAttack,
|
|
CharacterOptionId.IgnoreAllegianceRequests,
|
|
CharacterOptionId.IgnoreFellowshipRequests,
|
|
CharacterOptionId.FellowshipShareXP,
|
|
CharacterOptionId.AcceptLootPermits,
|
|
CharacterOptionId.FellowshipShareLoot,
|
|
CharacterOptionId.FellowshipAutoAcceptRequests,
|
|
CharacterOptionId.UseChargeAttack,
|
|
CharacterOptionId.ListenToAllegianceChat,
|
|
CharacterOptionId.ListenToGeneralChat,
|
|
CharacterOptionId.ListenToTradeChat,
|
|
CharacterOptionId.ListenToLFGChat,
|
|
CharacterOptionId.ListenToRoleplayChat,
|
|
CharacterOptionId.AppearOffline,
|
|
CharacterOptionId.LeadMissileTargets,
|
|
CharacterOptionId.UseFastMissiles,
|
|
CharacterOptionId.ListenToSocietyChat,
|
|
CharacterOptionId.ShowHelm,
|
|
CharacterOptionId.UseMouseTurning,
|
|
CharacterOptionId.ShowCloak,
|
|
CharacterOptionId.LockUI,
|
|
];
|
|
|
|
// wire research §8.2 — PlayerModule::GetDefaultOptionValue @0x005D2A30,
|
|
// byte-verified 0x2B-byte table at VA 0x005D2A5C. 16 default-ON ids
|
|
// (every id past 0x2A falls off the end of that table and defaults to
|
|
// false, even though 3 of them are ON in the raw constructor word —
|
|
// see the divergence register row, D3/OP1).
|
|
private static readonly CharacterOptionId[] ClientDefaultOnIds =
|
|
[
|
|
CharacterOptionId.AutoRepeatAttack,
|
|
CharacterOptionId.IgnoreFellowshipRequests,
|
|
CharacterOptionId.AllowGive,
|
|
CharacterOptionId.ShowTooltips,
|
|
CharacterOptionId.ToggleRun,
|
|
CharacterOptionId.AutoTarget,
|
|
CharacterOptionId.VividTargetingIndicator,
|
|
CharacterOptionId.FellowshipShareXP,
|
|
CharacterOptionId.CoordinatesOnRadar,
|
|
CharacterOptionId.SpellDuration,
|
|
CharacterOptionId.UseChargeAttack,
|
|
CharacterOptionId.ListenToAllegianceChat,
|
|
CharacterOptionId.ListenToGeneralChat,
|
|
CharacterOptionId.ListenToTradeChat,
|
|
CharacterOptionId.ListenToLFGChat,
|
|
CharacterOptionId.LeadMissileTargets,
|
|
];
|
|
|
|
[Fact]
|
|
public void All_HasExactly53Entries_Ids0x00Through0x34Contiguous()
|
|
{
|
|
CharacterOptionTableEntry[] all = [.. CharacterOptionTable.All];
|
|
|
|
Assert.Equal(53, all.Length);
|
|
for (uint id = 0x00; id <= 0x34; id++)
|
|
{
|
|
Assert.True(
|
|
CharacterOptionTable.TryGet(id, out CharacterOptionTableEntry entry),
|
|
$"id 0x{id:X2} missing from CharacterOptionTable");
|
|
Assert.Equal(id, (uint)entry.Id);
|
|
}
|
|
}
|
|
|
|
[Theory]
|
|
[MemberData(nameof(AllModeledIds))]
|
|
public void IsAutoSave_MatchesByteVerifiedSplit(CharacterOptionId id)
|
|
{
|
|
bool expected = Array.IndexOf(AutoSaveIds, id) >= 0;
|
|
|
|
Assert.True(CharacterOptionTable.TryGet(id, out CharacterOptionTableEntry entry));
|
|
Assert.Equal(expected, entry.IsAutoSave);
|
|
}
|
|
|
|
[Theory]
|
|
[MemberData(nameof(AllModeledIds))]
|
|
public void ClientDefault_MatchesByteVerifiedSplit(CharacterOptionId id)
|
|
{
|
|
bool expected = Array.IndexOf(ClientDefaultOnIds, id) >= 0;
|
|
|
|
Assert.True(CharacterOptionTable.TryGet(id, out CharacterOptionTableEntry entry));
|
|
Assert.Equal(expected, entry.ClientDefault);
|
|
}
|
|
|
|
[Fact]
|
|
public void AutoSaveIds_CountIs21()
|
|
{
|
|
Assert.Equal(21, AutoSaveIds.Length);
|
|
Assert.Equal(21, CharacterOptionTable.All.Count(static e => e.IsAutoSave));
|
|
}
|
|
|
|
[Fact]
|
|
public void ClientDefaultOnIds_CountIs16()
|
|
{
|
|
Assert.Equal(16, ClientDefaultOnIds.Length);
|
|
Assert.Equal(16, CharacterOptionTable.All.Count(static e => e.ClientDefault));
|
|
}
|
|
|
|
[Fact]
|
|
public void ReconstructedClientDefaultWords_MatchIndependentlyConfirmedConstants()
|
|
{
|
|
// wire research §1.4/§2.5: OR'ing every ClientDefault=true row's mask
|
|
// into its own word reconstructs EXACTLY CharacterOptions1.Default
|
|
// (0x50C4A54A, also the retail constructor literal) for Options1,
|
|
// and 0x00008700 for Options2 — the client Defaults-button value,
|
|
// deliberately NOT the same as the raw constructor default
|
|
// (0x00948700, RuntimeCharacterOptionsState.DefaultOptions2) because
|
|
// GetDefaultOptionValue's table stops at id 0x2A.
|
|
uint options1 = 0u;
|
|
uint options2 = 0u;
|
|
foreach (CharacterOptionTableEntry entry in CharacterOptionTable.All)
|
|
{
|
|
if (!entry.ClientDefault) continue;
|
|
if (entry.IsOptions1) options1 |= entry.Mask;
|
|
else options2 |= entry.Mask;
|
|
}
|
|
|
|
Assert.Equal(0x50C4A54Au, options1);
|
|
Assert.Equal(0x00008700u, options2);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(0x35u)] // CharacterOptions1Default — the WHOLE default mask, not a real option
|
|
[InlineData(0x36u)] // CharacterOptions2Default — same landmine, other word
|
|
[InlineData(0xFFFFu)]
|
|
[InlineData(0xFFFFFFFFu)]
|
|
public void TryGet_RejectsUnknownAndReservedIds(uint optionId)
|
|
{
|
|
Assert.False(CharacterOptionTable.TryGet(optionId, out _));
|
|
}
|
|
|
|
[Fact]
|
|
public void SpotCheck_WordAndMaskAgainstVerbatimAcclientEnums()
|
|
{
|
|
// acclient.h:3404-3436 `enum CharacterOption` / :3451-3481
|
|
// `enum CharacterOptions2`.
|
|
Assert.True(CharacterOptionTable.TryGet(
|
|
CharacterOptionId.AutoRepeatAttack, out CharacterOptionTableEntry autoRepeat));
|
|
Assert.True(autoRepeat.IsOptions1);
|
|
Assert.Equal(0x00000002u, autoRepeat.Mask);
|
|
|
|
// PersistentAtDay (id 0x05) lives in Options2 despite its low id —
|
|
// acclient.h:3454 `PersistentAtDay_CharacterOptions2 = 0x1`.
|
|
Assert.True(CharacterOptionTable.TryGet(
|
|
CharacterOptionId.PersistentAtDay, out CharacterOptionTableEntry persistentAtDay));
|
|
Assert.False(persistentAtDay.IsOptions1);
|
|
Assert.Equal(0x00000001u, persistentAtDay.Mask);
|
|
|
|
Assert.True(CharacterOptionTable.TryGet(
|
|
CharacterOptionId.ListenToAllegianceChat, out CharacterOptionTableEntry allegiance));
|
|
Assert.True(allegiance.IsOptions1);
|
|
Assert.Equal(0x40000000u, allegiance.Mask);
|
|
|
|
// HearPkDeathMessages (0x34) — ACE-sourced, unverifiable against the
|
|
// 2013 binary; register row.
|
|
Assert.True(CharacterOptionTable.TryGet(
|
|
CharacterOptionId.HearPkDeathMessages, out CharacterOptionTableEntry pkDeath));
|
|
Assert.False(pkDeath.IsOptions1);
|
|
Assert.Equal(0x02000000u, pkDeath.Mask);
|
|
Assert.False(pkDeath.IsAutoSave);
|
|
}
|
|
|
|
public static IEnumerable<object[]> AllModeledIds()
|
|
{
|
|
for (uint id = 0x00; id <= 0x34; id++)
|
|
yield return [(CharacterOptionId)id];
|
|
}
|
|
}
|