feat(net): #18 holtburger inbound chat parity - EmoteText, SoulEmote, ServerMessage, PlayerKilled, WeenieError + Windows-1252 codec
Five sub-changes:
1. Windows-1252 codec switch (global). Every Encoding.ASCII call site
in src/AcDream.Core.Net/Messages/ -> Encoding.GetEncoding(1252).
Touched HearSpeech, ChatRequests, GameEvents, AppraiseInfoParser,
CharacterList, CreateObject, PlayerDescriptionParser, SocialActions.
New Encodings.cs module-init registers CodePagesEncodingProvider
(System.Text.Encoding.CodePages ships with .NET 10 SDK but isn't
auto-registered). Matches retail + holtburger; accented names
no longer round-trip-broken.
2. New parsers (opcodes confirmed against holtburger opcodes.rs):
- EmoteText (0x01E0) { u32 senderGuid, string16 senderName, string16 text }
- SoulEmote (0x01E2) same wire layout as EmoteText
- ServerMessage (0xF7E0) { string16 message, u32 chatType }
- PlayerKilled (0x019E) { string16 deathMessage, u32 victimGuid, u32 killerGuid }
Shared StringReader.cs has the CP1252 String16L primitive.
3. WorldSession dispatch. ProcessDatagram adds branches for the four
new top-level opcodes + fires session-level events (EmoteHeard,
SoulEmoteHeard, ServerMessageReceived, PlayerKilledReceived).
0x0295 SetTurbineChatChannels stubbed with TODO for parallel I.6.
4. GameEventWiring routes WeenieError + WeenieErrorWithString
(parsers existed but were unrouted) -> chat.OnWeenieError.
5. ChatLog adapters: Emote / SoulEmote ChatKind values, OnEmote,
OnSoulEmote, OnPlayerKilled, OnWeenieError. OnLocalSpeech now
substitutes empty sender -> "You" per holtburger client/messages.rs.
ChatVM.FormatEntry handles new kinds (asterisk + sender + text).
22 new tests covering parser round-trips + reject-bad-opcode +
ChatLog adapter coverage + Win-1252 round-trip with non-ASCII chars.
Solution total: 881 green (210->225 in Core.Net.Tests, 606->613 in Core.Tests).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b131514d51
commit
ff5ed9ec0b
25 changed files with 899 additions and 10 deletions
|
|
@ -90,4 +90,86 @@ public sealed class ChatLogTests
|
|||
log.Clear();
|
||||
Assert.Equal(0, log.Count);
|
||||
}
|
||||
|
||||
// ── Phase I.5: emote / soul-emote / killed / weenie-error adapters ──
|
||||
|
||||
[Fact]
|
||||
public void OnEmote_AppendsEmoteEntry()
|
||||
{
|
||||
var log = new ChatLog();
|
||||
log.OnEmote("Caith", "waves at you", 0xCAFE);
|
||||
var e = log.Snapshot()[0];
|
||||
Assert.Equal(ChatKind.Emote, e.Kind);
|
||||
Assert.Equal("Caith", e.Sender);
|
||||
Assert.Equal("waves at you", e.Text);
|
||||
Assert.Equal(0xCAFEu, e.SenderGuid);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OnSoulEmote_AppendsSoulEmoteEntry()
|
||||
{
|
||||
var log = new ChatLog();
|
||||
log.OnSoulEmote("Bob", "dances", 0xBEEF);
|
||||
var e = log.Snapshot()[0];
|
||||
Assert.Equal(ChatKind.SoulEmote, e.Kind);
|
||||
Assert.Equal("Bob", e.Sender);
|
||||
Assert.Equal("dances", e.Text);
|
||||
Assert.Equal(0xBEEFu, e.SenderGuid);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OnPlayerKilled_AppendsSystemEntry_StoresGuids()
|
||||
{
|
||||
var log = new ChatLog();
|
||||
log.OnPlayerKilled("Caith was killed by a Drudge.",
|
||||
victimGuid: 0x12345678u, killerGuid: 0x90ABCDEFu);
|
||||
var e = log.Snapshot()[0];
|
||||
Assert.Equal(ChatKind.System, e.Kind);
|
||||
Assert.Equal("Caith was killed by a Drudge.", e.Text);
|
||||
Assert.Equal(0x12345678u, e.SenderGuid);
|
||||
Assert.Equal(0x90ABCDEFu, e.ChannelId); // killer guid stashed here
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OnWeenieError_PlainCode_AppendsSystemEntry()
|
||||
{
|
||||
var log = new ChatLog();
|
||||
log.OnWeenieError(errorId: 0x1234, param: null);
|
||||
var e = log.Snapshot()[0];
|
||||
Assert.Equal(ChatKind.System, e.Kind);
|
||||
Assert.Contains("0x1234", e.Text);
|
||||
Assert.Equal(0x1234u, e.ChannelId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OnWeenieError_WithString_AppendsInterpolation()
|
||||
{
|
||||
var log = new ChatLog();
|
||||
log.OnWeenieError(errorId: 0x5678, param: "Mana Stone");
|
||||
var e = log.Snapshot()[0];
|
||||
Assert.Equal(ChatKind.System, e.Kind);
|
||||
Assert.Contains("Mana Stone", e.Text);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OnLocalSpeech_EmptySender_SubstitutesYou()
|
||||
{
|
||||
// Holtburger client/messages.rs lines 476-487 — empty sender
|
||||
// means the player is the speaker (echo back of their own
|
||||
// ranged shout). Substitute "You" so the chat line reads
|
||||
// "You: hello" instead of ": hello".
|
||||
var log = new ChatLog();
|
||||
log.OnLocalSpeech(sender: "", text: "hello", senderGuid: 0, isRanged: false);
|
||||
var e = log.Snapshot()[0];
|
||||
Assert.Equal("You", e.Sender);
|
||||
Assert.Equal("hello", e.Text);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OnLocalSpeech_NonEmptySender_KeepsAsIs()
|
||||
{
|
||||
var log = new ChatLog();
|
||||
log.OnLocalSpeech(sender: "Alice", text: "hi", senderGuid: 0xAA, isRanged: false);
|
||||
Assert.Equal("Alice", log.Snapshot()[0].Sender);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue