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:
Erik 2026-08-21 06:11:33 +02:00
parent 80a3a25594
commit 10304f6dc2
5 changed files with 164 additions and 28 deletions

View file

@ -688,14 +688,54 @@ public static class GameEventWiring
registrar.Register(GameEventType.MagicDispelEnchantment, e =>
{
var p = GameEvents.ParseMagicDispelEnchantment(e.Payload.Span);
if (p is not null) spellbook.OnEnchantmentRemoved(p.Value.Layer, p.Value.SpellId);
if (p is null) return;
spellbook.OnEnchantmentRemoved(p.Value.Layer, p.Value.SpellId);
NotifyOfEnchantmentRemoval((uint)p.Value.SpellId);
});
registrar.Register(GameEventType.MagicDispelMultipleEnchantments, e =>
{
var entries = GameEvents.ParseMagicLayeredSpellList(e.Payload.Span);
if (entries is not null)
spellbook.OnEnchantmentsRemoved(entries.Select(item => ((uint)item.SpellId, (uint)item.Layer)));
if (entries is null) return;
spellbook.OnEnchantmentsRemoved(entries.Select(item => ((uint)item.SpellId, (uint)item.Layer)));
foreach (var entry in entries)
NotifyOfEnchantmentRemoval((uint)entry.SpellId);
});
// Retail spell id 0x29A, special-cased by name in
// NotifyOfEnchantmentRemoval so the line reads "Vitae penalty has
// expired." rather than "Vitae has expired."
const uint VitaePenaltySpellId = 0x29Au;
// ClientMagicSystem::NotifyOfEnchantmentRemoval @ 0x005686C0. The
// server sends NO text for an enchantment leaving the PLAYER — it is
// the client that announces it. (Enchantments leaving an ITEM are
// different: those arrive as ordinary server chat, which is why item
// spells were the only ones showing up.)
void NotifyOfEnchantmentRemoval(uint spellId)
{
if (onInterfaceText is null)
return;
// Retail's own guards, in order: ids at or above 0x8000 are not
// spells and are skipped outright, and a spell missing from the
// table returns without printing.
if (spellId >= 0x8000
|| !spellbook.TryGetMetadata(spellId, out SpellMetadata meta))
{
return;
}
// Vitae reads "Vitae penalty has expired." — retail appends the
// word to the spell's own name for this one id.
string name = spellId == VitaePenaltySpellId
? meta.Name + " penalty"
: meta.Name;
// AddTextToScroll(text, 7, 1, 0). Retail's literal carries a
// trailing newline because its scroll appends raw text; AddText is
// line-based, so adding one here would print a blank line.
onInterfaceText($"{name} has expired.", RetailLogTextType.Magic);
}
registrar.Register(GameEventType.MagicPurgeEnchantments,
_ => spellbook.OnPurgeAll());
registrar.Register(GameEventType.MagicPurgeBadEnchantments,