feat(D.5.2): PublicUpdatePropertyInt (0x02CE) parser
New standalone parser for the server's live PropertyInt update targeting a VISIBLE object (carries guid). Wire layout: u32 opcode + u8 sequence + u32 guid + u32 property + i32 value (17 bytes total). The sequence byte is parsed-past but not honored (latest-wins; DR-4). The companion PrivateUpdatePropertyInt (0x02CD) targets the player's own object (no guid) and is not parsed here. Three tests: uiEffectsUpdate (round-trip guid/prop/value), wrongOpcode (returns null), truncated (returns null on 16-byte input). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8df0b64676
commit
242bc9286d
2 changed files with 80 additions and 0 deletions
|
|
@ -0,0 +1,36 @@
|
|||
using System.Buffers.Binary;
|
||||
using AcDream.Core.Net.Messages;
|
||||
|
||||
namespace AcDream.Core.Net.Tests.Messages;
|
||||
|
||||
public sealed class PublicUpdatePropertyIntTests
|
||||
{
|
||||
private static byte[] Build(uint guid, uint property, int value, byte seq = 1, uint opcode = 0x02CEu)
|
||||
{
|
||||
var b = new byte[17];
|
||||
BinaryPrimitives.WriteUInt32LittleEndian(b.AsSpan(0), opcode);
|
||||
b[4] = seq;
|
||||
BinaryPrimitives.WriteUInt32LittleEndian(b.AsSpan(5), guid);
|
||||
BinaryPrimitives.WriteUInt32LittleEndian(b.AsSpan(9), property);
|
||||
BinaryPrimitives.WriteInt32LittleEndian(b.AsSpan(13), value);
|
||||
return b;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryParse_uiEffectsUpdate_returnsGuidPropValue()
|
||||
{
|
||||
var p = PublicUpdatePropertyInt.TryParse(Build(0x50000001u, property: 18u, value: 0x9));
|
||||
Assert.NotNull(p);
|
||||
Assert.Equal(0x50000001u, p!.Value.Guid);
|
||||
Assert.Equal(18u, p.Value.Property);
|
||||
Assert.Equal(0x9, p.Value.Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryParse_wrongOpcode_returnsNull()
|
||||
=> Assert.Null(PublicUpdatePropertyInt.TryParse(Build(1, 18, 1, opcode: 0x02CDu)));
|
||||
|
||||
[Fact]
|
||||
public void TryParse_truncated_returnsNull()
|
||||
=> Assert.Null(PublicUpdatePropertyInt.TryParse(new byte[16]));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue