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
|
|
@ -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));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue