Wire (Core.Net):
- CharacterCreate.cs: outbound 0xF656 builder, byte-exact port of
Proto_UI::SendCharGenResult@0x00546a70 -> ACCharGenResult::Pack@0x005c7570
-> CG_Pack@0x005c7200. Account String16L first (packed outside CG_Pack),
then the constant-1 u32, heritage/gender, 14 appearance strip/style/color
u32s, 6 f64 shades (skin/hair/headgear/shirt/trousers/footwear, retail
order), template, 6 attributes, slot, classId, numSkills + exactly 55
u32 skill-advancement classes (ReadOnlySpan validated ==55, throws
ArgumentException otherwise — ACE terminates the session on any other
count via PlayerFactory.CreateResult.ClientServerSkillsMismatch), name
String16L, startArea, isAdmin, isEnvoy, and a trailing checksum whose
exact 19-term accumulation set (heritage+gender+3 strips+hairColor+
eyeColor+hairStyle+headgearStyle+shirtStyle+trousersStyle+footwearStyle+
template+6 attributes) is read byte-for-byte off CG_Pack's decompiled
accumulator (0x005c7213-0x005c74c3) — headgearColor/shirtColor/
trousersColor/footwearColor/shades/slot/classId are deliberately absent
from the sum despite sitting adjacent on the wire. Cross-checked against
ACE's CharacterCreateInfo.Unpack/Appearance.Unpack and holtburger's
CharacterCreateRequestData (types.rs:236-369), which agree on every
field and order. Retail routes via SendToLogon — the same queue
CharacterDelete already uses.
- CharGenVerificationResponse.cs (new): promotes the shared 0xF643 parse
out of CharacterRestore — full Code enum (Undef..AdminPrivilegeDenied=7,
ACE's CharacterGenerationVerificationResponse) plus the conditional
Ok-only identity payload (guid/String16L name/u32 secondsGreyedOut).
CharacterRestore.Parse now delegates to it; CharacterRestore's public
Parsed shape, Parse signature, and every existing test expectation are
UNCHANGED.
- PacketWriter.WriteDouble: f64 little-endian helper for the shade fields.
WorldSession dispatch (Core.Net):
- Added an awaiting-request latch (None/Restore/Create), armed by
SendRestoreCharacter/the new SendCharacterCreation immediately before
each send (SendCharacterCreation builds the body first so a skill-count
throw never arms the latch for a request that was never sent), cleared
the instant a matching 0xF643 is dispatched (success OR parse failure —
a malformed reply must never wedge the latch open) and on Dispose.
0xF643 now routes to CharacterRestoreReceived or the new
CharacterCreateResponseReceived (Action<CharGenVerificationResponse.Parsed>)
by that latch; an unexpected 0xF643 with nothing outstanding logs once
and is dropped, never misattributed. Fixed
WorldSessionCharacterSelectionTests' restore-dispatch test, which
previously fed a bare CharacterRestore response with no preceding
SendRestoreCharacter — that shape is now the "no outstanding request"
drop path by design.
Status events (Runtime + Launcher.Core, contract first):
- Amended docs/plans/2026-08-14-launcher-campaign.md §LA1's pinned status
vocabulary to add characterCreated{guid,name} (Ok reply identity, named
to mirror CharGenVerificationResponse's own fields and to read distinct
from enteredWorld — retail logs a freshly created character straight in
without a fresh characterList) and creationFailed{code,name} (raw Code
value + its enum member name).
- SessionStatusWriter.CharacterCreated/CreationFailed implement that
contract.
- Launcher.Core: CharacterCreatedStatusEvent/CreationFailedStatusEvent +
StatusEventParser cases, in lockstep.
Tests: CharacterCreateTests (byte-exact layout incl. checksum term-set,
55-slot fixture, wrong-count throws), CharGenVerificationResponseTests
(every Code value), WorldSessionCharacterCreationTests (create-then-
response routes correctly, restore unaffected, no-outstanding drop,
second-response-after-consumed drop, Dispose clears the latch, a builder
throw never arms it), SessionStatusWriterTests + Launcher.Core
StatusEventParserTests/StatusFileTailerTests (pinned shape + tailer
round-trip) for the two new events.
Verified: dotnet build AcDream.slnx -c Release — 0 errors. Full solution
test run green (Core.Net.Tests 993/993, Runtime.Tests 1667/1667,
Launcher.Core.Tests 323/323, plus every other project in the solution).
WSL Ubuntu: Core.Net.Tests 993/993, Runtime.Tests 1667/1667.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
110 lines
4 KiB
C#
110 lines
4 KiB
C#
using System.Buffers.Binary;
|
|
using AcDream.Core.Net.Messages;
|
|
|
|
namespace AcDream.Core.Net.Tests.Messages;
|
|
|
|
/// <summary>
|
|
/// Campaign CC CC2: the shared 0xF643 parser both CharacterRestore and
|
|
/// CharacterCreate responses consume. See <see cref="CharacterRestoreTests"/>
|
|
/// for the pre-existing CharacterRestore-shaped coverage that must survive
|
|
/// this type's promotion unchanged.
|
|
/// </summary>
|
|
public sealed class CharGenVerificationResponseTests
|
|
{
|
|
[Fact]
|
|
public void Parse_Ok_PopulatesIdentityPayload()
|
|
{
|
|
var w = AceWireWriter.GameMessage(CharGenVerificationResponse.ResponseOpcode)
|
|
.Write((uint)CharGenVerificationResponse.Code.Ok)
|
|
.WriteGuid(0x5000000Bu)
|
|
.WriteString16L("+NewChar")
|
|
.Write(0u);
|
|
|
|
CharGenVerificationResponse.Parsed parsed =
|
|
CharGenVerificationResponse.Parse(w.ToArray());
|
|
|
|
Assert.Equal(1u, parsed.RawCode);
|
|
Assert.Equal(CharGenVerificationResponse.Code.Ok, parsed.AsCode);
|
|
Assert.True(parsed.IsOk);
|
|
Assert.Equal(0x5000000Bu, parsed.Guid);
|
|
Assert.Equal("+NewChar", parsed.Name);
|
|
Assert.Equal(0u, parsed.SecondsGreyedOut);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(0u, CharGenVerificationResponse.Code.Undef)]
|
|
[InlineData(2u, CharGenVerificationResponse.Code.Pending)]
|
|
[InlineData(3u, CharGenVerificationResponse.Code.NameInUse)]
|
|
[InlineData(4u, CharGenVerificationResponse.Code.NameBanned)]
|
|
[InlineData(5u, CharGenVerificationResponse.Code.Corrupt)]
|
|
[InlineData(6u, CharGenVerificationResponse.Code.DatabaseDown)]
|
|
[InlineData(7u, CharGenVerificationResponse.Code.AdminPrivilegeDenied)]
|
|
public void Parse_EveryNonOkCode_IsFlagOnlyWithNullTrailingFields(
|
|
uint rawCode,
|
|
CharGenVerificationResponse.Code expectedCode)
|
|
{
|
|
var w = AceWireWriter.GameMessage(CharGenVerificationResponse.ResponseOpcode)
|
|
.Write(rawCode);
|
|
|
|
CharGenVerificationResponse.Parsed parsed =
|
|
CharGenVerificationResponse.Parse(w.ToArray());
|
|
|
|
Assert.Equal(rawCode, parsed.RawCode);
|
|
Assert.Equal(expectedCode, parsed.AsCode);
|
|
Assert.False(parsed.IsOk);
|
|
Assert.Null(parsed.Guid);
|
|
Assert.Null(parsed.Name);
|
|
Assert.Null(parsed.SecondsGreyedOut);
|
|
}
|
|
|
|
[Fact]
|
|
public void Parse_UnknownCode_NeverThrowsOnTheCast()
|
|
{
|
|
// A plain enum cast never throws in C# — a private-server or future
|
|
// retail revision sending a code we haven't named yet must not crash
|
|
// the parser.
|
|
var w = AceWireWriter.GameMessage(CharGenVerificationResponse.ResponseOpcode)
|
|
.Write(99u);
|
|
|
|
CharGenVerificationResponse.Parsed parsed =
|
|
CharGenVerificationResponse.Parse(w.ToArray());
|
|
|
|
Assert.Equal(99u, parsed.RawCode);
|
|
Assert.Equal((CharGenVerificationResponse.Code)99u, parsed.AsCode);
|
|
Assert.False(parsed.IsOk);
|
|
}
|
|
|
|
[Fact]
|
|
public void Parse_WrongOpcode_Throws()
|
|
{
|
|
byte[] bytes = new byte[4];
|
|
BinaryPrimitives.WriteUInt32LittleEndian(bytes, 0xDEADBEEFu);
|
|
|
|
Assert.Throws<FormatException>(() => CharGenVerificationResponse.Parse(bytes));
|
|
}
|
|
|
|
[Fact]
|
|
public void Parse_TruncatedAfterCode_Throws()
|
|
{
|
|
var w = AceWireWriter.GameMessage(CharGenVerificationResponse.ResponseOpcode)
|
|
.Write((uint)CharGenVerificationResponse.Code.Ok);
|
|
|
|
Assert.Throws<FormatException>(() => CharGenVerificationResponse.Parse(w.ToArray()));
|
|
}
|
|
|
|
[Fact]
|
|
public void Parse_TruncatedBeforeCode_Throws()
|
|
{
|
|
var w = AceWireWriter.GameMessage(CharGenVerificationResponse.ResponseOpcode);
|
|
|
|
Assert.Throws<FormatException>(() => CharGenVerificationResponse.Parse(w.ToArray()));
|
|
}
|
|
|
|
[Fact]
|
|
public void ResponseOpcode_MatchesCharacterRestoresResponseOpcode()
|
|
{
|
|
// The whole point of this type: both families collide on the exact
|
|
// same wire opcode.
|
|
Assert.Equal(CharacterRestore.ResponseOpcode, CharGenVerificationResponse.ResponseOpcode);
|
|
}
|
|
}
|