fix(chat): CH3 review fixes — phantom UN-9, allegiance-broadcast echo, /a legacy fallback
Applies the Opus review of Campaign CH slice CH3 (614a1e05):
- B1: UN-9 was a phantom divergence — ACE's CharacterOptions1.cs:47
OR-sum is 0x50C4A54A (its own comment confirms 1355064650), identical
to acdream's literal. The wrong 0x50C48D4A existed only in the research
doc. Row deleted, register §5 reverted to 4 rows, research doc corrected
with dated notes.
- S1/S4: AllegianceBroadcast (0x02000000) is a server-echoing channel —
ACE's GameActionChatChannel handler includes the sender in its real-name
Allegiance.Members broadcast (retail's DoAllegianceBroadcast has no
AddTextToScroll), so the client must skip its local optimistic echo, not
keep it. ChatChannelInfo.Legacy.IsSelfEchoChannel() now returns true for
it; RouteLegacyChannel's comment corrected; Turbine.IsSelfEchoChannel()'s
backwards comment rewritten truthfully.
- S3: retail's /a stays on the legacy AllegianceBroadcast bitflag until
StartupTurbineChatSystem successfully starts Turbine chat — "never
started" (TurbineChatState.Enabled == false) now falls back to legacy in
both LiveSessionCommandRouter.RouteChat and
DirectGameRuntimeCommandAdapter.TrySendChannel, while "enabled but no
allegiance room" still correctly refuses locally.
- S5: added a LiveSessionEventRouter test proving the Options.Replace ->
OnCharacterOptionsChanged seeding order, and RuntimeSettingsTargets /
GameWindowLiveSessionOwnershipTests tests proving the concrete
ICommandBus.Publish wiring and the single LiveSessionCommandSurface
construction site.
- S6: AP-181 rewritten to name both of retail's omitted pre-send checks
(IsMessageSafe silent-drop, then IsMessageSpam) and stop misattributing
either to RouteLegacyChannel, which has no such gates.
- N1-N7: CharacterOptionId moved below SocialActions so its doc comment
re-attaches; TurbineChatMembershipGate reuses TurbineChatDisplayNames
instead of a duplicate table; the gate-to-refusal-text mapping is now
shared via TurbineChatMembershipGate.ResolveRefusalText instead of
duplicated in both hosts; ChatSettings.Default now matches ACE's real
CharacterOptions2.Default (Roleplay/Society start off); a doc-comment
clarifies only the five Hear toggles are server-backed; the register's
§3 header recounted 129 -> 128.
Suite: 11,964 passed / 4 skipped / 0 failed (baseline 11,957/4/0 + 7 new
tests). Campaign ledger CH3 review column updated to APPROVE-WITH-FIXES.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
d3f1c21835
commit
e07fba5731
21 changed files with 582 additions and 153 deletions
|
|
@ -100,6 +100,28 @@ public sealed class GameWindowLiveSessionOwnershipTests
|
|||
StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ProductionSourceConstructsOnlyOneLiveSessionCommandSurface()
|
||||
{
|
||||
// CH3 review S5(b): LiveSessionCommandSurface has no dependencies of
|
||||
// its own — CH3 deliberately hoisted its single construction site
|
||||
// (SessionPlayerComposition.cs) so RuntimeSettingsTargets and the
|
||||
// retained UI's chat/inventory panels share the SAME generation-
|
||||
// gated command route. A second construction site anywhere under
|
||||
// src/AcDream.App would silently split that route into two, each
|
||||
// with its own activation/dispose lifecycle.
|
||||
string root = FindRepositoryRoot();
|
||||
string appRoot = Path.Combine(root, "src", "AcDream.App");
|
||||
|
||||
int total = Directory
|
||||
.EnumerateFiles(appRoot, "*.cs", SearchOption.AllDirectories)
|
||||
.Sum(path => CountOccurrences(
|
||||
File.ReadAllText(path),
|
||||
"new LiveSessionCommandSurface("));
|
||||
|
||||
Assert.Equal(1, total);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("TryStartLiveSession")]
|
||||
[InlineData("ClearInboundEntityState")]
|
||||
|
|
|
|||
|
|
@ -174,19 +174,29 @@ public sealed class LiveSessionCommandRouterTests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void AllegianceWithNoRoom_RefusesLocally_NeverDowngradesToLegacyChannel()
|
||||
public void AllegianceTurbineEnabledButNoRoom_RefusesLocally_NeverDowngradesToLegacyChannel()
|
||||
{
|
||||
// The CH3 headline /a bug (research doc §5.3): retail's @a is bound
|
||||
// unconditionally to Turbine — no allegiance must refuse locally,
|
||||
// NOT silently fall through to the legacy AllegianceBroadcast
|
||||
// bitflag.
|
||||
// S3 (CH3 Opus review, 2026-08-09) corrected the original CH3
|
||||
// headline /a fix (research doc §5.3): retail's @a is bound to
|
||||
// Turbine only once StartupTurbineChatSystem succeeds — i.e. once
|
||||
// Turbine chat is ENABLED. With Turbine up but no allegiance room
|
||||
// (this test), retail hits SendTurbineChat's own roomId<=0 branch
|
||||
// and refuses locally — it must NOT fall through to the legacy
|
||||
// AllegianceBroadcast bitflag. (Contrast the Enabled==false case
|
||||
// below, which DOES fall back — Turbine was never started at all.)
|
||||
var communication = new RuntimeCommunicationState();
|
||||
var legacySent = new List<(uint Id, string Text)>();
|
||||
var turbineSent = new List<string>();
|
||||
var turbine = new TurbineChatState();
|
||||
turbine.OnChannelsReceived(
|
||||
allegianceRoom: 0u, generalRoom: 0x70000001u, tradeRoom: 0u,
|
||||
lfgRoom: 0u, roleplayRoom: 0u, olthoiRoom: 0u, societyRoom: 0u,
|
||||
societyCelestialHandRoom: 0u, societyEldrytchWebRoom: 0u,
|
||||
societyRadiantBloodRoom: 0u); // Enabled = true, AllegianceRoom stays 0
|
||||
var router = NewRouter(
|
||||
chat: communication.Chat,
|
||||
communication: communication,
|
||||
turbine: new TurbineChatState(), // AllegianceRoom stays 0
|
||||
turbine: turbine,
|
||||
sendChannel: (id, text) => legacySent.Add((id, text)),
|
||||
sendTurbine: (_, _, _, _, text, _) => turbineSent.Add(text));
|
||||
router.Activate();
|
||||
|
|
@ -201,10 +211,40 @@ public sealed class LiveSessionCommandRouterTests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void AllegianceBroadcast_AbVerbChannel_RoutesLegacyWithSelfEcho()
|
||||
public void AllegianceTurbineNeverStarted_FallsBackToLegacyAllegianceBroadcast()
|
||||
{
|
||||
// S3 (CH3 Opus review, 2026-08-09): retail's BASE binding keeps /a
|
||||
// on the legacy AllegianceBroadcast (0x02000000) channel until
|
||||
// Turbine chat successfully starts and StartupTurbineChatSystem
|
||||
// rebinds it (research doc §4.3) — with NO 0x0295
|
||||
// SetTurbineChatChannels ever received, retail does not print
|
||||
// "Turbine chat is not available." (that refusal only exists once
|
||||
// the Turbine-bound verb has actually been armed).
|
||||
var chat = new ChatLog();
|
||||
var legacySent = new List<(uint Id, string Text)>();
|
||||
var turbineSent = new List<string>();
|
||||
var router = NewRouter(
|
||||
chat: chat,
|
||||
turbine: new TurbineChatState(), // never received SetTurbineChatChannels
|
||||
sendChannel: (id, text) => legacySent.Add((id, text)),
|
||||
sendTurbine: (_, _, _, _, text, _) => turbineSent.Add(text));
|
||||
router.Activate();
|
||||
|
||||
router.Publish(new SendChatCmd(ChatChannelKind.Allegiance, null, "guild hi"));
|
||||
|
||||
Assert.Equal([(0x02000000u, "guild hi")], legacySent);
|
||||
Assert.Empty(turbineSent);
|
||||
// S1: AllegianceBroadcast is now a server-echoing channel — no
|
||||
// local optimistic echo.
|
||||
Assert.Equal(0, chat.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AllegianceBroadcast_AbVerbChannel_RoutesLegacyWithNoLocalEcho()
|
||||
{
|
||||
// /ab (retail DoAllegianceBroadcast) rides the legacy 0x0147 pipe —
|
||||
// distinct from /a, which is always Turbine now.
|
||||
// distinct from /a, which routes through Turbine whenever Turbine
|
||||
// chat is enabled (see the two Allegiance tests above).
|
||||
var chat = new ChatLog();
|
||||
var legacySent = new List<(uint Id, string Text)>();
|
||||
var router = NewRouter(
|
||||
|
|
@ -216,13 +256,10 @@ public sealed class LiveSessionCommandRouterTests
|
|||
ChatChannelKind.AllegianceBroadcast, null, "to the whole allegiance"));
|
||||
|
||||
Assert.Equal([(0x02000000u, "to the whole allegiance")], legacySent);
|
||||
Assert.Collection(
|
||||
chat.Snapshot(),
|
||||
entry =>
|
||||
{
|
||||
Assert.Equal(ChatKind.Channel, entry.Kind);
|
||||
Assert.Equal("Allegiance", entry.ChannelName);
|
||||
});
|
||||
// S1 (CH3 Opus review): ACE's GameActionChatChannel handler
|
||||
// includes the sender in its real-name Allegiance.Members
|
||||
// broadcast, so the client must NOT also echo locally.
|
||||
Assert.Equal(0, chat.Count);
|
||||
}
|
||||
|
||||
// ── Campaign CH slice CH3: per-channel self-echo matrix ──
|
||||
|
|
@ -252,8 +289,15 @@ public sealed class LiveSessionCommandRouterTests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void AllegianceBroadcast_KeepsLocalOptimisticEcho()
|
||||
public void AllegianceBroadcast_SkipsLocalOptimisticEcho()
|
||||
{
|
||||
// S1 (CH3 Opus review, 2026-08-09): flips this test's original
|
||||
// (wrong) premise. ACE's GameActionChatChannel handler iterates
|
||||
// player.Allegiance.Members — the sender IS a member, so their own
|
||||
// line comes back with their real name through the SAME broadcast
|
||||
// every other member gets. Retail agrees:
|
||||
// ClientCommunicationSystem::DoAllegianceBroadcast @0x005761F0 has
|
||||
// no AddTextToScroll of its own. Keeping a local echo double-prints.
|
||||
var chat = new ChatLog();
|
||||
var router = NewRouter(
|
||||
chat: chat,
|
||||
|
|
@ -263,9 +307,7 @@ public sealed class LiveSessionCommandRouterTests
|
|||
router.Publish(new SendChatCmd(
|
||||
ChatChannelKind.AllegianceBroadcast, null, "hi"));
|
||||
|
||||
Assert.Equal(1, chat.Count); // real-name broadcast includes the
|
||||
// sender — no separate "" echo, so the
|
||||
// client keeps its own.
|
||||
Assert.Equal(0, chat.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using AcDream.App.Diagnostics;
|
||||
using AcDream.App.Net;
|
||||
using AcDream.App.Rendering;
|
||||
using AcDream.App.Settings;
|
||||
using AcDream.Core.Net.Messages;
|
||||
|
|
@ -243,6 +244,33 @@ public sealed class RuntimeSettingsControllerTests
|
|||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConcreteRuntimeTargetPublishesSetSingleCharacterOptionOntoTheBus()
|
||||
{
|
||||
// CH3 review S5(b): SaveChatPublishesSetSingleCharacterOption... above
|
||||
// only proves RuntimeSettingsController calls the IRuntimeSettingsTargets
|
||||
// INTERFACE (via the FakeRuntimeTargets test double) — nothing exercised
|
||||
// the CONCRETE RuntimeSettingsTargets.SetSingleCharacterOption, which is
|
||||
// the code that actually reaches the wire via ICommandBus.Publish. A
|
||||
// silent unwiring there (wrong record, wrong bus, dropped call) would
|
||||
// pass every test that only goes through the fake.
|
||||
var bus = new CaptureCommandBus();
|
||||
var target = new RuntimeSettingsTargets(
|
||||
new InspectingDisplayWindowTarget(static _ => { }),
|
||||
new RecordingQualityApplicationTarget([]),
|
||||
new RecordingUiLockTarget([]),
|
||||
bus,
|
||||
static _ => { });
|
||||
|
||||
target.SetSingleCharacterOption(
|
||||
(uint)CharacterOptionId.ListenToRoleplayChat, value: false);
|
||||
|
||||
var cmd = Assert.IsType<SetSingleCharacterOptionRuntimeCmd>(
|
||||
Assert.Single(bus.Published));
|
||||
Assert.Equal((uint)CharacterOptionId.ListenToRoleplayChat, cmd.OptionId);
|
||||
Assert.False(cmd.Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SettingsViewModelSavePreservesSectionAndTargetOrder()
|
||||
{
|
||||
|
|
@ -314,28 +342,30 @@ public sealed class RuntimeSettingsControllerTests
|
|||
dispatcher,
|
||||
static _ => { });
|
||||
|
||||
// ChatSettings.Default starts every Hear*Chat bit true — flip one
|
||||
// off first so the second edit below can flip it back on.
|
||||
Assert.True(viewModel.ChatDraft.HearRoleplayChat);
|
||||
viewModel.SetChat(viewModel.ChatDraft with { HearRoleplayChat = false });
|
||||
// N4 (CH3 Opus review): ChatSettings.Default now matches ACE's real
|
||||
// CharacterOptions2.Default — Roleplay/Society start FALSE (only
|
||||
// General/Trade/LFG start true). Flip Roleplay ON first so the
|
||||
// second edit below can flip it back off.
|
||||
Assert.False(viewModel.ChatDraft.HearRoleplayChat);
|
||||
viewModel.SetChat(viewModel.ChatDraft with { HearRoleplayChat = true });
|
||||
viewModel.Save();
|
||||
|
||||
Assert.Equal(
|
||||
[((uint)CharacterOptionId.ListenToRoleplayChat, false)],
|
||||
[((uint)CharacterOptionId.ListenToRoleplayChat, true)],
|
||||
targets.SingleOptionCalls);
|
||||
|
||||
targets.SingleOptionCalls.Clear();
|
||||
viewModel.SetChat(viewModel.ChatDraft with
|
||||
{
|
||||
HearRoleplayChat = true,
|
||||
HearSocietyChat = false,
|
||||
HearRoleplayChat = false,
|
||||
HearSocietyChat = true,
|
||||
});
|
||||
viewModel.Save();
|
||||
|
||||
Assert.Equal(
|
||||
[
|
||||
((uint)CharacterOptionId.ListenToRoleplayChat, true),
|
||||
((uint)CharacterOptionId.ListenToSocietyChat, false),
|
||||
((uint)CharacterOptionId.ListenToRoleplayChat, false),
|
||||
((uint)CharacterOptionId.ListenToSocietyChat, true),
|
||||
],
|
||||
targets.SingleOptionCalls);
|
||||
}
|
||||
|
|
@ -363,9 +393,20 @@ public sealed class RuntimeSettingsControllerTests
|
|||
public void SyncChatFromServerOptionsReseedsPersistedAndDraft()
|
||||
{
|
||||
// Research doc §5.2: ACE's CharacterOptions2.Default omits
|
||||
// HearRoleplayChat/HearSocietyChat even though acdream's local
|
||||
// ChatSettings.Default claims both are on.
|
||||
var storage = new FakeStorage();
|
||||
// HearRoleplayChat/HearSocietyChat. N4 (CH3 Opus review) aligned
|
||||
// ChatSettings.Default to that same stance, so this test now seeds
|
||||
// storage with an explicitly stale PERSISTED value (both on — e.g.
|
||||
// a save from before N4, or a user who had enabled them) to prove
|
||||
// the server sync corrects local state to the server's truth,
|
||||
// rather than merely observing the two already agree.
|
||||
var storage = new FakeStorage
|
||||
{
|
||||
ChatValue = ChatSettings.Default with
|
||||
{
|
||||
HearRoleplayChat = true,
|
||||
HearSocietyChat = true,
|
||||
},
|
||||
};
|
||||
var controller = new RuntimeSettingsController(
|
||||
storage,
|
||||
static preset => QualitySettings.From(preset),
|
||||
|
|
@ -417,17 +458,16 @@ public sealed class RuntimeSettingsControllerTests
|
|||
static _ => { });
|
||||
storage.ClearEvents();
|
||||
|
||||
// ChatSettings.Default already has all five Hear*Chat bits on —
|
||||
// options2 with only those five bits set (any other bits are
|
||||
// irrelevant, the sync only masks these) reproduces exactly that,
|
||||
// so the sync must be a true no-op.
|
||||
const uint allFiveHearBitsOn =
|
||||
// N4 (CH3 Opus review): ChatSettings.Default now matches ACE's real
|
||||
// CharacterOptions2.Default exactly — General/Trade/LFG on,
|
||||
// Roleplay/Society off. Syncing with that SAME bit pattern (any
|
||||
// other bits are irrelevant, the sync only masks these five) must
|
||||
// be a true no-op.
|
||||
const uint aceDefaultHearBits =
|
||||
(uint)PlayerDescriptionParser.CharacterOptions2.HearGeneralChat
|
||||
| (uint)PlayerDescriptionParser.CharacterOptions2.HearTradeChat
|
||||
| (uint)PlayerDescriptionParser.CharacterOptions2.HearLFGChat
|
||||
| (uint)PlayerDescriptionParser.CharacterOptions2.HearRoleplayChat
|
||||
| (uint)PlayerDescriptionParser.CharacterOptions2.HearSocietyChat;
|
||||
controller.SyncChatFromServerOptions(allFiveHearBitsOn);
|
||||
| (uint)PlayerDescriptionParser.CharacterOptions2.HearLFGChat;
|
||||
controller.SyncChatFromServerOptions(aceDefaultHearBits);
|
||||
|
||||
Assert.Equal(0, storage.ChatSaves);
|
||||
}
|
||||
|
|
@ -1061,6 +1101,17 @@ public sealed class RuntimeSettingsControllerTests
|
|||
}
|
||||
}
|
||||
|
||||
// CH3 review S5(b): records every ICommandBus.Publish call so a test can
|
||||
// assert what the CONCRETE RuntimeSettingsTargets actually put on the
|
||||
// bus, rather than only what the IRuntimeSettingsTargets fake recorded.
|
||||
private sealed class CaptureCommandBus : ICommandBus
|
||||
{
|
||||
public readonly List<object> Published = new();
|
||||
|
||||
public void Publish<T>(T command) where T : notnull =>
|
||||
Published.Add(command!);
|
||||
}
|
||||
|
||||
private sealed class InspectingDisplayWindowTarget(
|
||||
Action<DisplaySettings> apply)
|
||||
: IRuntimeDisplayWindowTarget
|
||||
|
|
|
|||
|
|
@ -32,13 +32,19 @@ public sealed class ChatChannelInfoTests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void Legacy_AllegianceBroadcastBitflag_IsNOTSelfEcho()
|
||||
public void Legacy_AllegianceBroadcastBitflag_IsSelfEcho()
|
||||
{
|
||||
// 0x02000000 AllegianceBroadcast is the read-only motd channel —
|
||||
// server does not echo client messages back on it (per holtburger
|
||||
// chat.rs:492-507 predicate, only Fellow+Vassals+Patron+Monarch+CoVassals).
|
||||
// S1 (CH3 Opus review, 2026-08-09): flips this test's original
|
||||
// (wrong) premise. ACE's GameActionChatChannel handler iterates
|
||||
// player.Allegiance.Members — the sender IS a member, so their own
|
||||
// line comes back with their real name through the SAME broadcast
|
||||
// every other member gets (a different mechanism from holtburger's
|
||||
// documented empty-sender resend for Fellow/Vassals/Patron/Monarch/
|
||||
// CoVassals, but the same self-echo consequence). Retail agrees:
|
||||
// ClientCommunicationSystem::DoAllegianceBroadcast @0x005761F0 has
|
||||
// no AddTextToScroll of its own.
|
||||
var c = new ChatChannelInfo.Legacy(0x02000000u, "AllegianceBroadcast");
|
||||
Assert.False(c.IsSelfEchoChannel());
|
||||
Assert.True(c.IsSelfEchoChannel());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -159,6 +159,54 @@ public sealed class TurbineChatMembershipGateTests
|
|||
ChatChannelKindLite.Society, turbine, options, false).Status);
|
||||
}
|
||||
|
||||
// ── N3 (CH3 Opus review): shared refusal-text mapping ──
|
||||
|
||||
[Fact]
|
||||
public void ResolveRefusalText_AllowedGate_ReturnsNull()
|
||||
{
|
||||
TurbineChatState turbine = ReceivedRooms();
|
||||
var options = new RuntimeCharacterOptionsState();
|
||||
TurbineChatGateResult gate = TurbineChatMembershipGate.Evaluate(
|
||||
ChatChannelKindLite.General, turbine, options, isOlthoiPlayer: false);
|
||||
|
||||
Assert.Equal(TurbineChatGateStatus.Allowed, gate.Status);
|
||||
Assert.Null(TurbineChatMembershipGate.ResolveRefusalText(gate));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ResolveRefusalText_UnavailableGate_ReturnsRetailUnavailableString()
|
||||
{
|
||||
var turbine = new TurbineChatState(); // never received SetTurbineChatChannels
|
||||
var options = new RuntimeCharacterOptionsState();
|
||||
TurbineChatGateResult gate = TurbineChatMembershipGate.Evaluate(
|
||||
ChatChannelKindLite.General, turbine, options, isOlthoiPlayer: false);
|
||||
|
||||
(string Text, RetailLogTextType Type)? refusal =
|
||||
TurbineChatMembershipGate.ResolveRefusalText(gate);
|
||||
|
||||
Assert.NotNull(refusal);
|
||||
Assert.Equal(ClientTextRefusals.TurbineChatUnavailable, refusal!.Value.Text);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ResolveRefusalText_NotListeningGate_ReturnsWeenieErrorString()
|
||||
{
|
||||
TurbineChatState turbine = ReceivedRooms();
|
||||
var options = new RuntimeCharacterOptionsState();
|
||||
options.Replace(options.Options1, 0u); // every Hear*Chat bit off
|
||||
TurbineChatGateResult gate = TurbineChatMembershipGate.Evaluate(
|
||||
ChatChannelKindLite.General, turbine, options, isOlthoiPlayer: false);
|
||||
|
||||
(string Text, RetailLogTextType Type)? refusal =
|
||||
TurbineChatMembershipGate.ResolveRefusalText(gate);
|
||||
|
||||
Assert.NotNull(refusal);
|
||||
(string? expectedText, RetailLogTextType expectedType) =
|
||||
WeenieErrorMessages.Resolve(0x0551u, gate.DisplayName);
|
||||
Assert.Equal(expectedText, refusal!.Value.Text);
|
||||
Assert.Equal(expectedType, refusal.Value.Type);
|
||||
}
|
||||
|
||||
private static TurbineChatState ReceivedRooms(
|
||||
uint allegianceRoom = 0x10u,
|
||||
uint generalRoom = 0x11u,
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
using System.Buffers.Binary;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using AcDream.Core.Chat;
|
||||
using AcDream.Core.Combat;
|
||||
using AcDream.Core.Items;
|
||||
using AcDream.Core.Net;
|
||||
using AcDream.Core.Net.Messages;
|
||||
using AcDream.Core.Player;
|
||||
using AcDream.Core.Properties;
|
||||
using AcDream.Core.Social;
|
||||
|
|
@ -238,6 +240,56 @@ public sealed class LiveSessionEventRouterTests
|
|||
router.Dispose();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PlayerDescription_ReplacesOptionsBeforeInvokingOnCharacterOptionsChanged()
|
||||
{
|
||||
// CH3 review S5(a): the §6.4 seeding chain
|
||||
// (LiveSessionEventRouter.cs:208-212) is
|
||||
// `character.Character.Options.Replace(...)` THEN
|
||||
// `character.OnCharacterOptionsChanged?.Invoke(...)`. Nothing
|
||||
// previously asserted this glue lambda itself — only
|
||||
// GameEventWiring.WireAll's own onCharacterOptions?.Invoke — so a
|
||||
// silent unwiring of either half would go unnoticed by the suite.
|
||||
using var session = NewSession();
|
||||
var character = new RuntimeCharacterState();
|
||||
var observed = new List<(uint Options1, uint Options2, uint LiveOptions1AtCallback)>();
|
||||
|
||||
var router = new LiveSessionEventRouter(
|
||||
session,
|
||||
NoOpEntitySink(),
|
||||
NoOpEnvironmentSink(),
|
||||
NewInventoryBindings(),
|
||||
new LiveCharacterSessionBindings(
|
||||
new CombatState(),
|
||||
character,
|
||||
ResolveSkillFormulaBonus: null,
|
||||
OnSkillsUpdated: null,
|
||||
OnConfirmationRequest: null,
|
||||
OnConfirmationDone: null,
|
||||
ClientTime: () => 0d,
|
||||
OnCharacterOptionsChanged: (options1, options2) =>
|
||||
observed.Add((options1, options2, character.Options.Options1))),
|
||||
NewSocialBindings());
|
||||
router.Attach();
|
||||
|
||||
session.GameEvents.Dispatch(
|
||||
GameEventEnvelope.TryParse(
|
||||
WrapPlayerDescriptionEnvelope(0x50C4A54Au, 0x00948700u))!.Value);
|
||||
|
||||
var (options1, options2, liveOptions1AtCallback) = Assert.Single(observed);
|
||||
Assert.Equal(0x50C4A54Au, options1);
|
||||
Assert.Equal(0x00948700u, options2);
|
||||
// If Replace ran AFTER the callback (or not at all), a listener
|
||||
// reading character.Options from inside the callback — exactly
|
||||
// what a Settings-panel seed handler does — would observe the
|
||||
// stale default instead of the just-received value.
|
||||
Assert.Equal(0x50C4A54Au, liveOptions1AtCallback);
|
||||
Assert.Equal(0x50C4A54Au, character.Options.Options1);
|
||||
Assert.Equal(0x00948700u, character.Options.Options2);
|
||||
|
||||
router.Dispose();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NestedRouters_DisposeOlderFirstLeavesOnlyNewerRouter()
|
||||
{
|
||||
|
|
@ -382,7 +434,7 @@ public sealed class LiveSessionEventRouterTests
|
|||
const uint playerGuid = 0x50000001u;
|
||||
var objects = new ClientObjectTable();
|
||||
var character = new RuntimeCharacterState();
|
||||
character.InstallSpellMetadata(SpellTable.LoadFromReader(new StringReader(
|
||||
character.InstallSpellMetadata(SpellTable.LoadFromReader(new System.IO.StringReader(
|
||||
"Spell ID,Name,Flags [Hex]\n42,Strength Test,0x4\n")));
|
||||
int movementStatsUpdated = 0;
|
||||
|
||||
|
|
@ -621,6 +673,38 @@ public sealed class LiveSessionEventRouterTests
|
|||
new FriendsState(),
|
||||
new SquelchState());
|
||||
|
||||
// Minimal PlayerDescription (0x0013) body carrying only the
|
||||
// CharacterOptions1/2 trailer fields — mirrors
|
||||
// GameEventWiringTests.WireAll_PlayerDescription_PublishesCharacterOptions's
|
||||
// fixture layout.
|
||||
private static byte[] WrapPlayerDescriptionEnvelope(uint options1, uint options2)
|
||||
{
|
||||
var stream = new MemoryStream();
|
||||
using (var writer = new BinaryWriter(stream, System.Text.Encoding.UTF8, leaveOpen: true))
|
||||
{
|
||||
writer.Write(0u); // property flags
|
||||
writer.Write(0x52u); // player weenie type
|
||||
writer.Write(0u); // vector flags
|
||||
writer.Write(0u); // has health
|
||||
writer.Write(0x40u); // option flags: CharacterOptions2
|
||||
writer.Write(options1);
|
||||
writer.Write(0u); // legacy hotbar count
|
||||
writer.Write(0u); // spellbook filters
|
||||
writer.Write(options2);
|
||||
writer.Write(0u); // inventory count
|
||||
writer.Write(0u); // equipped count
|
||||
}
|
||||
|
||||
byte[] payload = stream.ToArray();
|
||||
byte[] body = new byte[GameEventEnvelope.HeaderSize + payload.Length];
|
||||
BinaryPrimitives.WriteUInt32LittleEndian(body, GameEventEnvelope.Opcode);
|
||||
BinaryPrimitives.WriteUInt32LittleEndian(body.AsSpan(4), 0u);
|
||||
BinaryPrimitives.WriteUInt32LittleEndian(body.AsSpan(8), 0u);
|
||||
BinaryPrimitives.WriteUInt32LittleEndian(body.AsSpan(12), (uint)GameEventType.PlayerDescription);
|
||||
Array.Copy(payload, 0, body, GameEventEnvelope.HeaderSize, payload.Length);
|
||||
return body;
|
||||
}
|
||||
|
||||
private static WorldSession NewSession() =>
|
||||
new(new IPEndPoint(IPAddress.Loopback, 9));
|
||||
|
||||
|
|
|
|||
|
|
@ -8,14 +8,18 @@ namespace AcDream.UI.Abstractions.Tests.Panels.Settings;
|
|||
public sealed class ChatSettingsTests
|
||||
{
|
||||
[Fact]
|
||||
public void Default_values_are_all_channels_on_with_timestamps_and_filter()
|
||||
public void Default_values_match_AceCharacterOptions2Default_stance()
|
||||
{
|
||||
// N4 (CH3 Opus review): ACE's real CharacterOptions2.Default
|
||||
// (0x00948700) turns General/Trade/LFG on but leaves Roleplay
|
||||
// (0x800) and Society (0x80000) off — this is no longer an
|
||||
// invented "all channels on" stance.
|
||||
var d = ChatSettings.Default;
|
||||
Assert.True(d.HearGeneralChat);
|
||||
Assert.True(d.HearTradeChat);
|
||||
Assert.True(d.HearLFGChat);
|
||||
Assert.True(d.HearRoleplayChat);
|
||||
Assert.True(d.HearSocietyChat);
|
||||
Assert.False(d.HearRoleplayChat);
|
||||
Assert.False(d.HearSocietyChat);
|
||||
Assert.False(d.AppearOffline);
|
||||
Assert.True(d.ShowTimestamps);
|
||||
Assert.True(d.FilterProfanity);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue