Campaign CT slice CT2: the client now learns the character's earned titles and current display title from the server, owns that state in Runtime, and can send a display-title change. No UI (CT3/CT4). Wire (Core.Net): - GameEvents.ParseCharacterTitleTable (0x0029 CharacterTitle): retail CharacterTitleTable::UnPack @0x005c6e90 skips a leading u32 into no field — its own Pack @0x005c6e40 always writes the literal 1 there, matching ACE's unconditional Writer.Write(1u) — then reads displayTitleId, then a count-prefixed PList<uint> of earned ids. - GameEvents.ParseUpdateTitle (0x002B UpdateTitle): titleId + setAsDisplay, per CM_Social::DispatchUI_AddOrSetCharacterTitle @0x006a54c0 -> Handle_Social__AddOrSetCharacterTitle @0x00564260, which ALWAYS adds (SendNotice_AddCharacterTitle, unconditional) and additionally sets display only when setAsDisplay != 0 (SendNotice_SetDisplayCharacterTitle, gated). - SocialActions.BuildTitleSet / WorldSession.SendSetTitle: outbound TitleSet (0x002C), u32 titleId, matching ACE's GameActionSetTitle. - GameEventWiring gains onCharacterTitleTable/onUpdateTitle delegate holes (Core.Net cannot reference AcDream.Runtime directly). Runtime: - New RuntimeCharacterTitleState (RuntimeCharacterState.Titles): earned title id set + display title id, TableReplaced/TitleAdded/ DisplayTitleChanged events matching retail's unconditional-add / gated-display-set contract, clears at generation reset. RuntimeCharacterOwnershipSnapshot/CaptureOwnership/IsConverged and RuntimeCharacterSnapshot extended (trailing optional fields, no existing call site broken). - IRuntimeCharacterCommands.SetTitle: generation-gated, sends TitleSet only — NO optimistic local mutation. Verified against retail's own CM_Social::Event_SetDisplayCharacterTitle @0x006a5720, which sends the wire message and touches no local field; the display title updates only from the server's own echo (the CA-campaign lesson: never re-add an optimistic write). Implemented on both hosts (DirectGameRuntimeCommandAdapter direct-send; CurrentGameRuntimeCommandAdapter via LiveCommandBus / LiveSessionCommandRouter's new SetTitleRuntimeCmd). - LiveSessionEventRouter wires the two inbound events unconditionally (RuntimeCharacterState.Titles is a required child, not an optional sibling like Fellowship/Allegiance). App (non-UI plumbing + resolver): - CharacterTitleResolver (src/AcDream.App/UI/Layout/): ports CharacterTitleTable::GetCharacterTitleFromID @0x005c6ed0 — titleId -> EnumMapper(0x22000041) canonical key -> compute_str_hash -> StringTable(0x2300000E) localized text. Runtime stays id-only; CT3/ CT4 consume this for display. DIDs hardcoded per the RetailKeyNames precedent (CT1 verified them end-to-end). Register: no new row. Retail's send path is non-optimistic and so is ours — no deviation to record for this slice. Tests: wire conformance (byte-exact + truncation) in CharacterTitleEventsTests.cs + SocialActionsTests.cs; Runtime owner unit tests in RuntimeCharacterTitleStateTests.cs plus integration in RuntimeCharacterStateTests.cs; a no-local-mutation command test in DirectGameRuntimeCommandAdapterTests.cs; an InstalledDat pin (CharacterTitleResolverLiveDatTests.cs, ids 0/1/2/3/5/13/14, run green with ACDREAM_RUN_INSTALLED_DAT_TESTS=1). Full solution build green; hermetic filtered suite green (15,380 passed / 0 failed). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
68 lines
2.9 KiB
C#
68 lines
2.9 KiB
C#
using AcDream.App.UI.Layout;
|
|
using AcDream.Content;
|
|
using DatReaderWriter;
|
|
|
|
namespace AcDream.App.Tests.UI.Layout;
|
|
|
|
/// <summary>
|
|
/// Campaign CT slice CT2 (2026-08-24) pin: <see cref="CharacterTitleResolver"/>
|
|
/// against the installed DAT set, end to end (EnumMapper 0x22000041 ->
|
|
/// compute_str_hash -> StringTable 0x2300000E). CT1's research doc
|
|
/// (docs/research/2026-08-24-campaign-ct-dat-ground-truth.md §5) verified
|
|
/// id 13 == "War Mage" against ACE's <c>CharacterTitle.WarMage</c>; this
|
|
/// pin adds several more low-ordinal ids from the same enum
|
|
/// (<c>CharacterTitle.cs</c>: Invalid=0, Adventurer=1, Archer=2,
|
|
/// Blademaster=3, LifeMage=5, Wayfarer=14) so a DAT revision or resolver
|
|
/// regression fails loudly instead of drifting unnoticed into CT3/CT4.
|
|
/// Follows the durable-pin pattern of <see cref="ChatStringsLiveDatTests"/>.
|
|
/// </summary>
|
|
[Trait("Lane", "InstalledDat")]
|
|
public sealed class CharacterTitleResolverLiveDatTests
|
|
{
|
|
private static string DatDirectory =>
|
|
Path.Combine(
|
|
System.Environment.GetFolderPath(System.Environment.SpecialFolder.UserProfile),
|
|
"Documents", "Asheron's Call");
|
|
|
|
[InstalledDatFact]
|
|
public void Resolve_PinsSeveralTitleIdsToTheirRetailDisplayStrings()
|
|
{
|
|
using var dats = new DatCollection(DatDirectory, DatReaderWriter.Options.DatAccessType.Read);
|
|
var resolver = new CharacterTitleResolver(new DatCollectionAdapter(dats));
|
|
|
|
// Retail's own early-return: id 0 (Invalid) never resolves.
|
|
Assert.Null(resolver.Resolve(0u));
|
|
|
|
Assert.Equal("Adventurer", resolver.Resolve(1u));
|
|
Assert.Equal("Archer", resolver.Resolve(2u));
|
|
Assert.Equal("Blademaster", resolver.Resolve(3u));
|
|
Assert.Equal("Life Mage", resolver.Resolve(5u));
|
|
Assert.Equal("War Mage", resolver.Resolve(13u));
|
|
Assert.Equal("Wayfarer", resolver.Resolve(14u));
|
|
}
|
|
|
|
[InstalledDatFact]
|
|
public void Resolve_UnmappedId_ReturnsNull()
|
|
{
|
|
using var dats = new DatCollection(DatDirectory, DatReaderWriter.Options.DatAccessType.Read);
|
|
var resolver = new CharacterTitleResolver(new DatCollectionAdapter(dats));
|
|
|
|
Assert.Null(resolver.Resolve(0xFFFFFFFEu));
|
|
}
|
|
|
|
[InstalledDatFact]
|
|
public void Resolve_CachesTheEnumMapperAcrossCalls()
|
|
{
|
|
// Not a durable behavioral pin — just confirms the lazy-load path
|
|
// used by the assertions above resolves the SAME value on a second
|
|
// call (the cached-mapper branch), not only on the first (cold) one.
|
|
using var dats = new DatCollection(DatDirectory, DatReaderWriter.Options.DatAccessType.Read);
|
|
var resolver = new CharacterTitleResolver(new DatCollectionAdapter(dats));
|
|
|
|
string? first = resolver.Resolve(13u);
|
|
string? second = resolver.Resolve(13u);
|
|
|
|
Assert.Equal("War Mage", first);
|
|
Assert.Equal(first, second);
|
|
}
|
|
}
|