feat(CT): CT2 — Runtime character-title ownership + wire
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>
This commit is contained in:
parent
d38f71cb28
commit
bcfddc97e7
23 changed files with 1044 additions and 17 deletions
|
|
@ -55,6 +55,10 @@ internal sealed record LiveSessionCommandBindings(
|
|||
// research §2.3-§2.7. No-ops when the batched module is clean, matching
|
||||
// retail's CPlayerModule::SaveToServer(force: 0).
|
||||
Action SaveCharacterOptions,
|
||||
// Campaign CT slice CT2 (2026-08-24): TitleSet (0x002C) — sends only, no
|
||||
// local mutation (RuntimeCharacterState.Titles updates from the
|
||||
// server's own echo).
|
||||
Action<uint> SendSetTitle,
|
||||
// Campaign FA slice FA2 (2026-08-12): fellowship + allegiance send
|
||||
// wrappers, the App-bus twin of DirectGameRuntimeCommandAdapter's
|
||||
// direct session.SendXxx calls.
|
||||
|
|
@ -95,6 +99,7 @@ internal readonly record struct SetSingleCharacterOptionRuntimeCmd(
|
|||
uint OptionId,
|
||||
bool Value);
|
||||
internal readonly record struct SaveCharacterOptionsRuntimeCmd;
|
||||
internal readonly record struct SetTitleRuntimeCmd(uint TitleId);
|
||||
internal readonly record struct AddFriendRuntimeCmd(string Name);
|
||||
internal readonly record struct RemoveFriendRuntimeCmd(uint CharacterId);
|
||||
|
||||
|
|
@ -228,6 +233,8 @@ internal sealed class LiveSessionCommandRouter : ILiveSessionCommandRouting
|
|||
command.Value)));
|
||||
commands.Register<SaveCharacterOptionsRuntimeCmd>(
|
||||
_ => SendIfActive(bindings.SaveCharacterOptions));
|
||||
commands.Register<SetTitleRuntimeCmd>(
|
||||
command => SendIfActive(() => bindings.SendSetTitle(command.TitleId)));
|
||||
commands.Register<AddFriendRuntimeCmd>(
|
||||
command => SendIfActive(() => bindings.AddFriend(command.Name)));
|
||||
commands.Register<OpenTradeNegotiationsRuntimeCmd>(
|
||||
|
|
|
|||
|
|
@ -770,6 +770,8 @@ internal sealed class LiveSessionRuntimeFactory
|
|||
CharacterState: _domain.Character,
|
||||
SendSingleCharacterOption: SendSingleCharacterOption,
|
||||
SaveCharacterOptions: SaveCharacterOptionsIfDirty,
|
||||
// Campaign CT slice CT2 (2026-08-24).
|
||||
SendSetTitle: session.SendSetTitle,
|
||||
// Campaign FA slice FA2 (2026-08-12): fellowship + allegiance send
|
||||
// wrappers, matching the WorldSession.SendXxx methods FA2 added.
|
||||
SendFellowshipCreate: session.SendFellowshipCreate,
|
||||
|
|
|
|||
|
|
@ -718,6 +718,31 @@ internal sealed class CurrentGameRuntimeCommandAdapter
|
|||
RuntimeCommandStatus.Accepted);
|
||||
}
|
||||
|
||||
public RuntimeCommandResult SetTitle(
|
||||
RuntimeGenerationToken expectedGeneration,
|
||||
uint titleId)
|
||||
{
|
||||
RuntimeCommandStatus gate = Validate(expectedGeneration, requireWorld: true);
|
||||
if (gate != RuntimeCommandStatus.Accepted)
|
||||
return Result(gate);
|
||||
if (titleId == 0u)
|
||||
{
|
||||
return EmitResult(
|
||||
RuntimeCommandDomain.Character,
|
||||
operation: 6,
|
||||
RuntimeCommandStatus.Rejected);
|
||||
}
|
||||
// CT2: NO optimistic local mutation — matches
|
||||
// DirectGameRuntimeCommandAdapter.SetTitle; RuntimeCharacterState.
|
||||
// Titles updates only from the server's own echo.
|
||||
_commands.Publish(new SetTitleRuntimeCmd(titleId));
|
||||
return EmitResult(
|
||||
RuntimeCommandDomain.Character,
|
||||
operation: 6,
|
||||
RuntimeCommandStatus.Accepted,
|
||||
titleId);
|
||||
}
|
||||
|
||||
public RuntimeCommandResult Execute(
|
||||
RuntimeGenerationToken expectedGeneration,
|
||||
in RuntimeFriendCommand command)
|
||||
|
|
|
|||
85
src/AcDream.App/UI/Layout/CharacterTitleResolver.cs
Normal file
85
src/AcDream.App/UI/Layout/CharacterTitleResolver.cs
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
using AcDream.Content;
|
||||
using DatReaderWriter.DBObjs;
|
||||
|
||||
namespace AcDream.App.UI.Layout;
|
||||
|
||||
/// <summary>
|
||||
/// Ports <c>CharacterTitleTable::GetCharacterTitleFromID @0x005c6ed0</c>'s
|
||||
/// title id -> display string chain: <c>EnumMapper(0x22000041)</c>
|
||||
/// canonical key name -> <c>compute_str_hash</c> ->
|
||||
/// <c>StringTable(0x2300000E)</c> localized text.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// Retail's chain is a two-level <c>DBObj::GetDIDByEnum</c> indirection
|
||||
/// through a master map (DID <c>0x25000000</c>): category 1 (EMAPPER) for
|
||||
/// the EnumMapper, category 4 (STRINGTABLE) for the StringTable. Both
|
||||
/// resolved DIDs are hardcoded here rather than porting the indirection
|
||||
/// generically — the same precedent <see cref="RetailKeyNames"/> already
|
||||
/// set for this exact category-4 family (its <c>KeyNameTableId</c>/
|
||||
/// <c>MetaKeyNameTableId</c>/<c>DelimiterTableId</c>); factor out a shared
|
||||
/// helper only if a THIRD consumer of <c>GetDIDByEnum</c> appears. Both DIDs
|
||||
/// were verified end-to-end against ACE's <c>CharacterTitle.WarMage = 13</c>
|
||||
/// in Campaign CT slice CT1
|
||||
/// (docs/research/2026-08-24-campaign-ct-dat-ground-truth.md §5, pinned by
|
||||
/// <c>CharacterPanelLiveDatTests.TitleStringTable_ResolvesWarMageEndToEnd</c>).
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// <see cref="AcDream.Runtime.Gameplay.RuntimeCharacterTitleState"/> stays
|
||||
/// id-only (the #368 headless-bot-observes-the-same-owner contract); this
|
||||
/// resolver is the App-layer seam CT3 (Titles page) and CT4 (header
|
||||
/// identity line) consume for display strings.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public sealed class CharacterTitleResolver
|
||||
{
|
||||
/// <summary>EnumMapper DID — title id -> canonical key name (e.g.
|
||||
/// "ID_CharacterTitle_War_Mage").</summary>
|
||||
public const uint TitleEnumMapperId = 0x22000041u;
|
||||
|
||||
/// <summary>StringTable DID — canonical key hash -> localized text.</summary>
|
||||
public const uint TitleStringTableId = 0x2300000Eu;
|
||||
|
||||
private readonly IDatReaderWriter _dats;
|
||||
private readonly DatStringResolver _strings;
|
||||
private EnumMapper? _titleEnumMapper;
|
||||
private bool _loadedMapper;
|
||||
|
||||
public CharacterTitleResolver(IDatReaderWriter dats)
|
||||
{
|
||||
_dats = dats ?? throw new ArgumentNullException(nameof(dats));
|
||||
_strings = new DatStringResolver(dats);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves one title id to its localized display string. Returns null
|
||||
/// for id 0 (retail's own early-return in
|
||||
/// <c>GetCharacterTitleFromID</c>), an id absent from the EnumMapper, or
|
||||
/// an unlocalized string — matching
|
||||
/// <see cref="DatStringResolver.Resolve(uint, uint, int)"/>'s own
|
||||
/// null-on-miss contract.
|
||||
/// </summary>
|
||||
public string? Resolve(uint titleId)
|
||||
{
|
||||
if (titleId == 0u)
|
||||
return null;
|
||||
|
||||
if (!_loadedMapper)
|
||||
{
|
||||
_dats.Portal.TryGet<EnumMapper>(TitleEnumMapperId, out _titleEnumMapper);
|
||||
_loadedMapper = true;
|
||||
}
|
||||
|
||||
if (_titleEnumMapper is null
|
||||
|| !_titleEnumMapper.IdToStringMap.TryGetValue(titleId, out var rawNameValue))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
string rawName = rawNameValue.ToString();
|
||||
if (string.IsNullOrEmpty(rawName))
|
||||
return null;
|
||||
|
||||
return _strings.Resolve(TitleStringTableId, DatStringResolver.ComputeHash(rawName));
|
||||
}
|
||||
}
|
||||
|
|
@ -138,7 +138,15 @@ public static class GameEventWiring
|
|||
// in GameEventType since the wire catalog with nothing behind them,
|
||||
// so until this wiring the bytes arrived and were dropped.
|
||||
Action<IReadOnlyDictionary<uint, ContractTracker>>? onContractTable = null,
|
||||
Action<ContractTrackerUpdate>? onContractUpdate = null)
|
||||
Action<ContractTrackerUpdate>? onContractUpdate = null,
|
||||
// Campaign CT slice CT2 (2026-08-24): the title-table (0x0029) and
|
||||
// add/set-display (0x002B) delegate holes. RuntimeCharacterState.
|
||||
// Titles is an AcDream.Runtime type — Core.Net cannot reference
|
||||
// AcDream.Runtime directly, so these are delegate holes exactly like
|
||||
// every other Runtime-owned sink above. Optional/nullable so every
|
||||
// existing caller compiles unchanged.
|
||||
Action<uint /*displayTitleId*/, IReadOnlyList<uint> /*titleIds*/>? onCharacterTitleTable = null,
|
||||
Action<uint /*titleId*/, bool /*setAsDisplay*/>? onUpdateTitle = null)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(dispatcher);
|
||||
ArgumentNullException.ThrowIfNull(items);
|
||||
|
|
@ -474,6 +482,24 @@ public static class GameEventWiring
|
|||
});
|
||||
}
|
||||
|
||||
// ── Character titles (Campaign CT slice CT2, 2026-08-24) ────────
|
||||
if (onCharacterTitleTable is not null)
|
||||
{
|
||||
registrar.Register(GameEventType.CharacterTitle, e =>
|
||||
{
|
||||
var p = GameEvents.ParseCharacterTitleTable(e.Payload.Span);
|
||||
if (p is not null) onCharacterTitleTable(p.Value.DisplayTitleId, p.Value.TitleIds);
|
||||
});
|
||||
}
|
||||
if (onUpdateTitle is not null)
|
||||
{
|
||||
registrar.Register(GameEventType.UpdateTitle, e =>
|
||||
{
|
||||
var p = GameEvents.ParseUpdateTitle(e.Payload.Span);
|
||||
if (p is not null) onUpdateTitle(p.Value.TitleId, p.Value.SetAsDisplay);
|
||||
});
|
||||
}
|
||||
|
||||
if (onConfirmationRequest is not null)
|
||||
{
|
||||
registrar.Register(GameEventType.CharacterConfirmationRequest, e =>
|
||||
|
|
|
|||
|
|
@ -869,6 +869,73 @@ public static class GameEvents
|
|||
public static FellowshipFellowStatsDone ParseFellowshipFellowStatsDone(ReadOnlySpan<byte> payload)
|
||||
=> new(payload.Length >= 4 ? BinaryPrimitives.ReadUInt32LittleEndian(payload) : null);
|
||||
|
||||
// ── Character titles (Campaign CT slice CT2, 2026-08-24) ────────────────
|
||||
|
||||
/// <summary>
|
||||
/// <c>0x0029 CharacterTitle</c> — retail <c>CharacterTitleTable::UnPack
|
||||
/// @0x005c6e90</c> (named-retail pseudo-C offset 471514-471526). The
|
||||
/// FIRST u32 is advanced past but never stored into any field — retail's
|
||||
/// own <c>CharacterTitleTable::Pack @0x005c6e40</c> (offset 471494-471510)
|
||||
/// always writes the literal constant <c>1</c> there
|
||||
/// (<c>**(uint32_t**)arg2 = 1</c>), and ACE's
|
||||
/// <c>GameEventCharacterTitle.cs</c> matches with an unconditional
|
||||
/// <c>Writer.Write(1u)</c> — a version/format tag retail itself discards
|
||||
/// on read, not meaningful gameplay data (CT2 task item 1). Then the
|
||||
/// current display title id (<c>mDisplayTitle</c>), then the
|
||||
/// count-prefixed <c>PList<uint></c> of every earned title id
|
||||
/// (<c>mTitleList</c>).
|
||||
/// </summary>
|
||||
public readonly record struct CharacterTitleTable(
|
||||
uint DisplayTitleId,
|
||||
IReadOnlyList<uint> TitleIds);
|
||||
|
||||
public static CharacterTitleTable? ParseCharacterTitleTable(ReadOnlySpan<byte> payload)
|
||||
{
|
||||
try
|
||||
{
|
||||
int pos = 0;
|
||||
_ = FellowshipReadU32(payload, ref pos); // discarded pack-version tag — see doc comment above
|
||||
uint displayTitleId = FellowshipReadU32(payload, ref pos);
|
||||
uint count = FellowshipReadU32(payload, ref pos);
|
||||
// PList<uint>::UnPack stores a 32-bit count bounded only by the
|
||||
// remaining packet — same generous guard as
|
||||
// SocialStateMessages.ParseFriendsUpdate.
|
||||
if (count > 65_536) return null;
|
||||
var titleIds = new uint[count];
|
||||
for (int i = 0; i < titleIds.Length; i++)
|
||||
titleIds[i] = FellowshipReadU32(payload, ref pos);
|
||||
return new CharacterTitleTable(displayTitleId, titleIds);
|
||||
}
|
||||
catch (FormatException) { return null; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <c>0x002B UpdateTitle</c> — retail's dispatch entry
|
||||
/// <c>CM_Social::DispatchUI_AddOrSetCharacterTitle @0x006a54c0</c> reads
|
||||
/// exactly <c>titleId</c> then <c>setAsDisplay</c> and forwards to
|
||||
/// <c>ClientUISystem::Handle_Social__AddOrSetCharacterTitle
|
||||
/// @0x00564260</c>, which ALWAYS broadcasts
|
||||
/// <c>SendNotice_AddCharacterTitle(titleId)</c> (a title just earned is
|
||||
/// unconditionally added to the earned set) and, only when
|
||||
/// <c>setAsDisplay != 0</c>, ALSO broadcasts
|
||||
/// <c>SendNotice_SetDisplayCharacterTitle(titleId)</c>. ACE's
|
||||
/// <c>GameEventUpdateTitle.cs</c>: <c>u32 title, u32
|
||||
/// setAsDisplayTitle</c> — matches exactly.
|
||||
/// </summary>
|
||||
public readonly record struct UpdateTitle(uint TitleId, bool SetAsDisplay);
|
||||
|
||||
public static UpdateTitle? ParseUpdateTitle(ReadOnlySpan<byte> payload)
|
||||
{
|
||||
try
|
||||
{
|
||||
int pos = 0;
|
||||
uint titleId = FellowshipReadU32(payload, ref pos);
|
||||
bool setAsDisplay = FellowshipReadU32(payload, ref pos) != 0u;
|
||||
return new UpdateTitle(titleId, setAsDisplay);
|
||||
}
|
||||
catch (FormatException) { return null; }
|
||||
}
|
||||
|
||||
private static FellowMember ReadFellow(ReadOnlySpan<byte> payload, ref int pos, uint guid)
|
||||
{
|
||||
uint cpCache = FellowshipReadU32(payload, ref pos);
|
||||
|
|
|
|||
|
|
@ -52,6 +52,16 @@ public static class SocialActions
|
|||
public const uint FellowshipAssignNewLeaderOpcode = 0x0290u; // u32 newLeaderGuid
|
||||
public const uint FellowshipChangeOpennessOpcode = 0x0291u; // u32 isOpen (0/1) — the REAL openness toggle
|
||||
|
||||
// Character titles (Campaign CT slice CT2, 2026-08-24). ACE
|
||||
// GameActionType.TitleSet = 0x002C; GameActionSetTitle.cs reads exactly
|
||||
// one u32 title id (session.Player.HandleActionSetTitle(title)). Retail
|
||||
// sender CM_Social::Event_SetDisplayCharacterTitle @0x006a5720 (verified
|
||||
// in the named pseudo-C): builds a 0x10-byte OrderHdr'd body whose
|
||||
// payload is [u32 0x2c][u32 titleId] and sends via
|
||||
// Proto_UI::SendToWeenie — no local state touched (see CT2's report: no
|
||||
// optimistic mutation, matching this slice's CA-lesson design).
|
||||
public const uint TitleSetOpcode = 0x002Cu; // u32 titleId
|
||||
|
||||
// Character options
|
||||
// CH3 (2026-08-09): the full-blob SetCharacterOptions (0x01A1) builder
|
||||
// and the string-payload AddChannel/RemoveChannel (0x0145/0x0146)
|
||||
|
|
@ -230,6 +240,17 @@ public static class SocialActions
|
|||
return body;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the character's display title — <c>0x002C TitleSet</c>. Retail's
|
||||
/// <c>Event_SetDisplayCharacterTitle</c> sends this and touches NO local
|
||||
/// state; the display title updates only when the server echoes back
|
||||
/// <c>UpdateTitle (0x002B)</c> with <c>setAsDisplay=true</c> (CT2: no
|
||||
/// optimistic local mutation, matching retail exactly — the CA-campaign
|
||||
/// lesson never re-add one).
|
||||
/// </summary>
|
||||
public static byte[] BuildTitleSet(uint seq, uint titleId)
|
||||
=> SingleGuid(seq, TitleSetOpcode, titleId);
|
||||
|
||||
/// <summary>
|
||||
/// Toggle one character option and push it to the server.
|
||||
/// <c>GameActionSetSingleCharacterOption @ GameActionType 0x0005</c> —
|
||||
|
|
|
|||
|
|
@ -2719,6 +2719,18 @@ public sealed class WorldSession : IDisposable
|
|||
spellbookFilters));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send retail <c>TitleSet (0x002C)</c> — sets the character's display
|
||||
/// title. Sends only; no local state changes here (Campaign CT slice
|
||||
/// CT2: retail's own send path is non-optimistic — see
|
||||
/// <see cref="SocialActions.BuildTitleSet"/>).
|
||||
/// </summary>
|
||||
public void SendSetTitle(uint titleId)
|
||||
{
|
||||
uint seq = NextGameActionSequence();
|
||||
SendGameAction(SocialActions.BuildTitleSet(seq, titleId));
|
||||
}
|
||||
|
||||
public void SendAddFriend(string name)
|
||||
{
|
||||
uint seq = NextGameActionSequence();
|
||||
|
|
|
|||
|
|
@ -268,6 +268,19 @@ public interface IRuntimeCharacterCommands
|
|||
/// production call sites — Apply, logout — pass <c>force = 0</c>).
|
||||
/// </summary>
|
||||
RuntimeCommandResult SaveOptions(RuntimeGenerationToken expectedGeneration);
|
||||
|
||||
/// <summary>
|
||||
/// Retail <c>TitleSet (GameActionType 0x002C)</c> — sets the character's
|
||||
/// display title (Campaign CT slice CT2, 2026-08-24;
|
||||
/// <c>CM_Social::Event_SetDisplayCharacterTitle @0x006a5720</c>). Sends
|
||||
/// only — no optimistic local mutation. The display title updates when
|
||||
/// the server echoes <c>UpdateTitle (0x002B)</c> with
|
||||
/// <c>setAsDisplay=true</c>, or the next <c>CharacterTitle (0x0029)</c>
|
||||
/// table arrives, through <c>RuntimeCharacterState.Titles</c>.
|
||||
/// </summary>
|
||||
RuntimeCommandResult SetTitle(
|
||||
RuntimeGenerationToken expectedGeneration,
|
||||
uint titleId);
|
||||
}
|
||||
|
||||
public enum RuntimeFriendCommandKind
|
||||
|
|
|
|||
|
|
@ -42,7 +42,11 @@ public readonly record struct RuntimeCharacterSnapshot(
|
|||
int ActiveEnchantmentCount,
|
||||
int DesiredComponentCount,
|
||||
int SkillCount,
|
||||
uint SpellbookFilters);
|
||||
uint SpellbookFilters,
|
||||
// Campaign CT slice CT2 (2026-08-24): trailing/optional so every
|
||||
// existing positional caller (GameRuntimeContractTests) compiles
|
||||
// unchanged.
|
||||
RuntimeCharacterTitleSnapshot Titles = default);
|
||||
|
||||
public readonly record struct RuntimeVitalSnapshot(
|
||||
int Kind,
|
||||
|
|
|
|||
|
|
@ -30,7 +30,18 @@ public readonly record struct RuntimeCharacterOwnershipSnapshot(
|
|||
/// still set — the ledger exists precisely to catch state a reset must
|
||||
/// clear but a value-only comparison would miss.
|
||||
/// </summary>
|
||||
bool OptionsAreClean = true)
|
||||
bool OptionsAreClean = true,
|
||||
/// <summary>
|
||||
/// Campaign CT slice CT2 (2026-08-24): the earned-title set's count —
|
||||
/// zero when <see cref="RuntimeCharacterState.Titles"/> has never
|
||||
/// received a table and after every reset.
|
||||
/// </summary>
|
||||
int TitleCount = 0,
|
||||
/// <summary>
|
||||
/// CT2: <c>Titles.DisplayTitleId == 0</c> — the client-constructor
|
||||
/// default (no display title id known yet).
|
||||
/// </summary>
|
||||
bool DisplayTitleIsDefault = true)
|
||||
{
|
||||
public bool IsConverged =>
|
||||
IsDisposed
|
||||
|
|
@ -47,7 +58,9 @@ public readonly record struct RuntimeCharacterOwnershipSnapshot(
|
|||
&& OptionsAreDefaults
|
||||
&& MovementSkillsAreReset
|
||||
&& AutonomyIsDefault
|
||||
&& OptionsAreClean;
|
||||
&& OptionsAreClean
|
||||
&& TitleCount == 0
|
||||
&& DisplayTitleIsDefault;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -104,6 +117,7 @@ public sealed class RuntimeCharacterState : IDisposable
|
|||
LocalPlayer = new LocalPlayerState(Spellbook);
|
||||
Options = new RuntimeCharacterOptionsState(timeProvider);
|
||||
MovementSkills = new RuntimeMovementSkillState();
|
||||
Titles = new RuntimeCharacterTitleState();
|
||||
View = new CharacterView(this);
|
||||
Spellbook.StateChanged += OnSpellbookChanged;
|
||||
Spellbook.EnchantmentsChanged += OnEnchantmentsChangedForMovement;
|
||||
|
|
@ -117,6 +131,11 @@ public sealed class RuntimeCharacterState : IDisposable
|
|||
public LocalPlayerState LocalPlayer { get; }
|
||||
public RuntimeCharacterOptionsState Options { get; }
|
||||
public RuntimeMovementSkillState MovementSkills { get; }
|
||||
/// <summary>Campaign CT slice CT2 (2026-08-24): earned titles + current
|
||||
/// display title (retail's <c>CharacterTitleTable</c>). Id-only —
|
||||
/// display-string resolution is an App-layer concern
|
||||
/// (<c>CharacterTitleResolver</c>).</summary>
|
||||
public RuntimeCharacterTitleState Titles { get; }
|
||||
public IRuntimeCharacterView View { get; }
|
||||
public bool IsDisposed => _disposed;
|
||||
|
||||
|
|
@ -232,7 +251,9 @@ public sealed class RuntimeCharacterState : IDisposable
|
|||
&& _jumpSkillBase == -1
|
||||
&& _movementSkillAugmentations == default,
|
||||
AutonomyLevel == FullAutonomyLevel,
|
||||
OptionsAreClean: !Options.IsDirty);
|
||||
OptionsAreClean: !Options.IsDirty,
|
||||
TitleCount: Titles.EarnedTitleIds.Count,
|
||||
DisplayTitleIsDefault: Titles.DisplayTitleId == 0u);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -445,6 +466,7 @@ public sealed class RuntimeCharacterState : IDisposable
|
|||
_movementSkillAugmentations = default;
|
||||
Volatile.Write(ref _autonomyLevel, FullAutonomyLevel);
|
||||
Try(MovementSkills.ResetSession, ref failures);
|
||||
Try(Titles.ResetSession, ref failures);
|
||||
if (failures is not null)
|
||||
{
|
||||
throw new AggregateException(
|
||||
|
|
@ -471,6 +493,7 @@ public sealed class RuntimeCharacterState : IDisposable
|
|||
_movementSkillAugmentations = default;
|
||||
Volatile.Write(ref _autonomyLevel, FullAutonomyLevel);
|
||||
Try(MovementSkills.ResetSession, ref failures);
|
||||
Try(Titles.ResetSession, ref failures);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
@ -526,7 +549,8 @@ public sealed class RuntimeCharacterState : IDisposable
|
|||
owner.Spellbook.ActiveEnchantments.Count(),
|
||||
owner.Spellbook.DesiredComponents.Count,
|
||||
owner.LocalPlayer.Skills.Count,
|
||||
owner.Spellbook.SpellbookFilters);
|
||||
owner.Spellbook.SpellbookFilters,
|
||||
owner.Titles.Snapshot);
|
||||
|
||||
public bool TryGetVital(int kind, out RuntimeVitalSnapshot vital)
|
||||
{
|
||||
|
|
@ -1189,3 +1213,125 @@ public sealed class RuntimeMovementSkillState
|
|||
Interlocked.Increment(ref _revision);
|
||||
}
|
||||
}
|
||||
|
||||
public readonly record struct RuntimeCharacterTitleSnapshot(
|
||||
uint DisplayTitleId,
|
||||
int TitleCount,
|
||||
long Revision);
|
||||
|
||||
/// <summary>
|
||||
/// Campaign CT slice CT2 (2026-08-24): retail's <c>CharacterTitleTable</c>
|
||||
/// (<c>mDisplayTitle</c> + <c>mTitleList</c>) ported into
|
||||
/// <see cref="RuntimeCharacterState"/>'s existing options/movement-skill
|
||||
/// sibling-owner shape. Two inbound wire events populate this: the full
|
||||
/// table (<c>0x0029 CharacterTitle</c>, <see cref="ReplaceTable"/>) and the
|
||||
/// incremental add/set-display notice (<c>0x002B UpdateTitle</c>,
|
||||
/// <see cref="ApplyUpdateTitle"/>). Runtime stays id-only — display-string
|
||||
/// resolution (EnumMapper -> hash -> StringTable,
|
||||
/// <c>CharacterTitleTable::GetCharacterTitleFromID @0x005c6ed0</c>) is an
|
||||
/// App-layer concern (<c>AcDream.App.UI.Layout.CharacterTitleResolver</c>),
|
||||
/// matching this class's presentation-independent contract and the #368
|
||||
/// headless-bot-observes-the-same-owner rule. Outbound
|
||||
/// <c>TitleSet (0x002C)</c> never mutates this state locally — retail's own
|
||||
/// <c>Event_SetDisplayCharacterTitle</c> send path touches no local field;
|
||||
/// the display title changes only when the server echoes back
|
||||
/// <c>UpdateTitle</c> (never re-add an optimistic write here — the CA
|
||||
/// campaign lesson).
|
||||
/// </summary>
|
||||
public sealed class RuntimeCharacterTitleState
|
||||
{
|
||||
private readonly object _gate = new();
|
||||
private readonly HashSet<uint> _earnedTitleIds = new();
|
||||
private uint _displayTitleId;
|
||||
private long _revision;
|
||||
|
||||
/// <summary>Fires after a full <c>0x0029 CharacterTitle</c> table replace.</summary>
|
||||
public event Action? TableReplaced;
|
||||
|
||||
/// <summary>
|
||||
/// Fires once per <c>0x002B UpdateTitle</c> arrival, UNCONDITIONALLY —
|
||||
/// matches retail's own <c>SendNotice_AddCharacterTitle</c>, which
|
||||
/// broadcasts regardless of whether the id was already in the earned
|
||||
/// set. Carries the added title id.
|
||||
/// </summary>
|
||||
public event Action<uint>? TitleAdded;
|
||||
|
||||
/// <summary>
|
||||
/// Fires whenever the display title id changes — from either a fresh
|
||||
/// <c>0x0029</c> table (a differing seed) or an <c>0x002B</c> whose
|
||||
/// <c>setAsDisplay</c> flag is set. Carries the NEW display title id.
|
||||
/// </summary>
|
||||
public event Action<uint>? DisplayTitleChanged;
|
||||
|
||||
public uint DisplayTitleId => Volatile.Read(ref _displayTitleId);
|
||||
public long Revision => Interlocked.Read(ref _revision);
|
||||
|
||||
public IReadOnlyCollection<uint> EarnedTitleIds
|
||||
{
|
||||
get { lock (_gate) return _earnedTitleIds.ToArray(); }
|
||||
}
|
||||
|
||||
public bool HasEarnedTitle(uint titleId)
|
||||
{
|
||||
lock (_gate) return _earnedTitleIds.Contains(titleId);
|
||||
}
|
||||
|
||||
public RuntimeCharacterTitleSnapshot Snapshot
|
||||
{
|
||||
get
|
||||
{
|
||||
int count;
|
||||
lock (_gate) count = _earnedTitleIds.Count;
|
||||
return new RuntimeCharacterTitleSnapshot(DisplayTitleId, count, Revision);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <c>0x0029 CharacterTitle</c> — a WHOLESALE authoritative replace
|
||||
/// (retail's <c>CharacterTitleTable::UnPack</c> always rebuilds
|
||||
/// <c>mTitleList</c> from scratch; there is no incremental-merge path
|
||||
/// on this opcode).
|
||||
/// </summary>
|
||||
public void ReplaceTable(uint displayTitleId, IReadOnlyList<uint> titleIds)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(titleIds);
|
||||
lock (_gate)
|
||||
{
|
||||
_earnedTitleIds.Clear();
|
||||
foreach (uint id in titleIds)
|
||||
_earnedTitleIds.Add(id);
|
||||
}
|
||||
bool displayChanged = DisplayTitleId != displayTitleId;
|
||||
Volatile.Write(ref _displayTitleId, displayTitleId);
|
||||
Interlocked.Increment(ref _revision);
|
||||
TableReplaced?.Invoke();
|
||||
if (displayChanged)
|
||||
DisplayTitleChanged?.Invoke(displayTitleId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <c>0x002B UpdateTitle</c> — retail's
|
||||
/// <c>ClientUISystem::Handle_Social__AddOrSetCharacterTitle</c>: ALWAYS
|
||||
/// add, and additionally set-display only when
|
||||
/// <paramref name="setAsDisplay"/> is true.
|
||||
/// </summary>
|
||||
public void ApplyUpdateTitle(uint titleId, bool setAsDisplay)
|
||||
{
|
||||
lock (_gate) _earnedTitleIds.Add(titleId);
|
||||
Interlocked.Increment(ref _revision);
|
||||
TitleAdded?.Invoke(titleId);
|
||||
if (setAsDisplay)
|
||||
{
|
||||
Volatile.Write(ref _displayTitleId, titleId);
|
||||
Interlocked.Increment(ref _revision);
|
||||
DisplayTitleChanged?.Invoke(titleId);
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetSession()
|
||||
{
|
||||
lock (_gate) _earnedTitleIds.Clear();
|
||||
Volatile.Write(ref _displayTitleId, 0u);
|
||||
Interlocked.Increment(ref _revision);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -723,6 +723,33 @@ public sealed class DirectGameRuntimeCommandAdapter
|
|||
RuntimeCommandStatus.Accepted);
|
||||
}
|
||||
|
||||
public RuntimeCommandResult SetTitle(
|
||||
RuntimeGenerationToken expectedGeneration,
|
||||
uint titleId)
|
||||
{
|
||||
RuntimeCommandStatus gate =
|
||||
Validate(expectedGeneration, out WorldSession? session);
|
||||
if (gate != RuntimeCommandStatus.Accepted)
|
||||
return Result(gate);
|
||||
if (titleId == 0u)
|
||||
{
|
||||
return EmitResult(
|
||||
RuntimeCommandDomain.Character,
|
||||
operation: 6,
|
||||
RuntimeCommandStatus.Rejected);
|
||||
}
|
||||
// CT2: NO optimistic local mutation — retail's own
|
||||
// Event_SetDisplayCharacterTitle send path touches no local state;
|
||||
// RuntimeCharacterState.Titles.DisplayTitleId updates only when the
|
||||
// server echoes UpdateTitle (0x002B) with setAsDisplay=true.
|
||||
session!.SendSetTitle(titleId);
|
||||
return EmitResult(
|
||||
RuntimeCommandDomain.Character,
|
||||
operation: 6,
|
||||
RuntimeCommandStatus.Accepted,
|
||||
titleId);
|
||||
}
|
||||
|
||||
public RuntimeCommandResult Execute(
|
||||
RuntimeGenerationToken expectedGeneration,
|
||||
in RuntimeFriendCommand command)
|
||||
|
|
|
|||
|
|
@ -345,7 +345,16 @@ public sealed class LiveSessionEventRouter : ILiveSessionEventRouting
|
|||
: null,
|
||||
onContractUpdate: social.Contracts is { } contractUpdate
|
||||
? contractUpdate.ApplyUpdate
|
||||
: null));
|
||||
: null,
|
||||
// Campaign CT slice CT2 (2026-08-24): RuntimeCharacterState.
|
||||
// Titles is a required child of the required `character.
|
||||
// Character` owner (not an optional sibling like Fellowship/
|
||||
// Allegiance/Trade/House above), so these are wired
|
||||
// unconditionally.
|
||||
onCharacterTitleTable: (displayTitleId, titleIds) =>
|
||||
character.Character.Titles.ReplaceTable(displayTitleId, titleIds),
|
||||
onUpdateTitle: (titleId, setAsDisplay) =>
|
||||
character.Character.Titles.ApplyUpdateTitle(titleId, setAsDisplay)));
|
||||
ConstructionCheckpoint();
|
||||
|
||||
// Campaign P Slice P1 (2026-07-30): burden recompute triggers —
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue