fix(chat): announce enchantment expiry; stop double-printing tells
Two of the four reported chat defects.
**Only item spells announced their expiry.** ACE splits the two cases: an
enchantment expiring on an ITEM arrives as ordinary server chat ("The spell X
on Y has expired.") — which is why those were the only ones showing — while
one expiring on the PLAYER arrives as GameEventMagicDispelEnchantment carrying
no text at all, because retail's client writes that line itself.
ClientMagicSystem::NotifyOfEnchantmentRemoval @0x005686C0 is now ported: the
spell's own name plus " has expired.", at LogTextType 7 (Magic), including
retail's guards (ids >= 0x8000 skipped, a spell missing from the table prints
nothing) and its one special case — spell 0x29A gets " penalty" appended so
vitae reads "Vitae penalty has expired."
Retail's trailing "\n" is deliberately dropped: its scroll appends raw text,
AddText is line-based, and keeping it would print a blank line.
**Every tell printed twice.** ACE's GameActionTell replies with a
GameMessageSystemChat carrying the finished "You tell X, ..." line
(ChatMessageType.OutgoingTell), and we ALSO emitted an optimistic local echo.
Retail's own send path, Event_TalkDirectByName @0x00577CF4, has no
AddTextToScroll beside it — it just transmits and lets the server's reply
print. The local echo is removed, which also makes Tell consistent with Say,
which has always relied on the server echo.
CH3 had this half-right: it removed the legacy-channel echo for precisely this
reason, but kept the Tell echo on the stated grounds that "the server never
resends" it. That premise was false. Both test comments asserting it are
corrected rather than deleted, since the wrong claim is what made the bug
survive review.
Solution builds clean; 14,477 tests pass on the standard hermetic lane filter,
0 failures.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
80a3a25594
commit
10304f6dc2
5 changed files with 164 additions and 28 deletions
|
|
@ -161,17 +161,18 @@ public sealed class LiveSessionCommandRouterTests
|
|||
|
||||
Assert.Equal([("Friend", "hello")], tells);
|
||||
Assert.Equal([(0x00000800u, "group")], channels);
|
||||
// CH3 (2026-08-09): Fellowship is one of the ACE server-echoing
|
||||
// legacy channels (resends with an empty sender) — the router must
|
||||
// NOT also emit a local optimistic echo, or the line double-prints.
|
||||
// Only the Tell echo (which the server never resends) survives.
|
||||
Assert.Collection(
|
||||
chat.Snapshot(),
|
||||
entry =>
|
||||
{
|
||||
Assert.Equal(ChatKind.Tell, entry.Kind);
|
||||
Assert.Equal("Friend", entry.Sender);
|
||||
});
|
||||
// CH3 (2026-08-09) got the Fellowship half right — ACE resends legacy
|
||||
// channel lines, so a local echo would double-print — but its stated
|
||||
// reason for keeping the Tell echo, "which the server never resends",
|
||||
// was wrong: ACE's GameActionTell replies with a GameMessageSystemChat
|
||||
// carrying the finished "You tell Friend, ..." line
|
||||
// (ChatMessageType.OutgoingTell). Tells double-printed in the chat
|
||||
// window for exactly that reason. Retail's own send path
|
||||
// @0x00577CF4 has no AddTextToScroll beside it either.
|
||||
//
|
||||
// So NEITHER emits a local echo now, and Say has always worked this
|
||||
// way.
|
||||
Assert.Empty(chat.Snapshot());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Buffers.Binary;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using AcDream.Core.Chat;
|
||||
|
|
@ -1813,6 +1814,99 @@ public sealed class GameEventWiringTests
|
|||
Assert.Empty(rentPayment);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An enchantment leaving the PLAYER is announced by the client, not the
|
||||
/// server — so nothing printed at all until this was wired.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// ACE splits the two cases: an enchantment expiring on an ITEM arrives as
|
||||
/// ordinary server chat ("The spell X on Y has expired."), which is why
|
||||
/// item spells were the only ones the player ever saw. One expiring on the
|
||||
/// player arrives as GameEventMagicDispelEnchantment carrying NO text,
|
||||
/// because retail's client writes the line itself —
|
||||
/// ClientMagicSystem::NotifyOfEnchantmentRemoval @0x005686C0, printed at
|
||||
/// LogTextType 7 (Magic).
|
||||
/// </remarks>
|
||||
[Fact]
|
||||
public void DispelledEnchantment_AnnouncesItsExpiryAtTheRetailTextType()
|
||||
{
|
||||
var lines = new List<(string Text, RetailLogTextType Type)>();
|
||||
var dispatcher = new GameEventDispatcher();
|
||||
GameEventWiring.WireAll(
|
||||
dispatcher,
|
||||
new ClientObjectTable(),
|
||||
new CombatState(),
|
||||
SpellbookWithNames(),
|
||||
new ChatLog(),
|
||||
onInterfaceText: (text, type) => lines.Add((text, type)));
|
||||
|
||||
dispatcher.Dispatch(GameEventEnvelope.TryParse(WrapEnvelope(
|
||||
GameEventType.MagicDispelEnchantment,
|
||||
DispelPayload(spellId: 1234, layer: 1)))!.Value);
|
||||
|
||||
Assert.Equal(
|
||||
("Fire Protection Self has expired.", RetailLogTextType.Magic),
|
||||
Assert.Single(lines));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DispelledVitaeReadsAsAPenalty()
|
||||
{
|
||||
// Retail appends " penalty" to this one spell's own name, so the line
|
||||
// reads "Vitae penalty has expired." rather than "Vitae has expired."
|
||||
var lines = new List<(string Text, RetailLogTextType Type)>();
|
||||
var dispatcher = new GameEventDispatcher();
|
||||
GameEventWiring.WireAll(
|
||||
dispatcher,
|
||||
new ClientObjectTable(),
|
||||
new CombatState(),
|
||||
SpellbookWithNames(),
|
||||
new ChatLog(),
|
||||
onInterfaceText: (text, type) => lines.Add((text, type)));
|
||||
|
||||
dispatcher.Dispatch(GameEventEnvelope.TryParse(WrapEnvelope(
|
||||
GameEventType.MagicDispelEnchantment,
|
||||
DispelPayload(spellId: 0x29A, layer: 1)))!.Value);
|
||||
|
||||
Assert.Equal("Vitae penalty has expired.", Assert.Single(lines).Text);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ADispelledSpellMissingFromTheTablePrintsNothing()
|
||||
{
|
||||
// Retail returns without printing when InqSpellBase fails, rather than
|
||||
// announcing a blank name.
|
||||
var lines = new List<(string Text, RetailLogTextType Type)>();
|
||||
var dispatcher = new GameEventDispatcher();
|
||||
GameEventWiring.WireAll(
|
||||
dispatcher,
|
||||
new ClientObjectTable(),
|
||||
new CombatState(),
|
||||
SpellbookWithNames(),
|
||||
new ChatLog(),
|
||||
onInterfaceText: (text, type) => lines.Add((text, type)));
|
||||
|
||||
dispatcher.Dispatch(GameEventEnvelope.TryParse(WrapEnvelope(
|
||||
GameEventType.MagicDispelEnchantment,
|
||||
DispelPayload(spellId: 4321, layer: 1)))!.Value);
|
||||
|
||||
Assert.Empty(lines);
|
||||
}
|
||||
|
||||
private static Spellbook SpellbookWithNames()
|
||||
=> new(SpellTable.LoadFromReader(new System.IO.StringReader(
|
||||
"Spell ID,Name,Flags [Hex]\n"
|
||||
+ "1234,Fire Protection Self,0x4\n"
|
||||
+ "666,Vitae,0x4\n")));
|
||||
|
||||
private static byte[] DispelPayload(ushort spellId, ushort layer)
|
||||
{
|
||||
byte[] payload = new byte[4];
|
||||
BinaryPrimitives.WriteUInt16LittleEndian(payload, spellId);
|
||||
BinaryPrimitives.WriteUInt16LittleEndian(payload.AsSpan(2), layer);
|
||||
return payload;
|
||||
}
|
||||
|
||||
private static byte[] BuildEnchantment(
|
||||
ushort spellId,
|
||||
ushort layer,
|
||||
|
|
|
|||
|
|
@ -47,10 +47,13 @@ public sealed class LiveChatCommandRouteTests
|
|||
"client:QueryAge",
|
||||
],
|
||||
sent);
|
||||
ChatEntry echo = Assert.Single(communication.Chat.Snapshot());
|
||||
Assert.Equal(ChatKind.Tell, echo.Kind);
|
||||
Assert.Equal("Bob", echo.Sender);
|
||||
Assert.Equal("secret", echo.Text);
|
||||
// A tell is SENT and nothing is echoed locally. The server returns the
|
||||
// "You tell Bob, ..." line itself (ACE GameActionTell ->
|
||||
// GameMessageSystemChat with ChatMessageType.OutgoingTell), and retail's
|
||||
// own send path @0x00577CF4 has no AddTextToScroll beside it — so an
|
||||
// optimistic echo here printed every tell TWICE in the chat window.
|
||||
// Say has always relied on the server echo for exactly this reason.
|
||||
Assert.Empty(communication.Chat.Snapshot());
|
||||
|
||||
route.Dispose();
|
||||
route.Publish(new SendServerCommandCmd("@stale"));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue