fix(net): sign-extend retail capacity bytes

Mirror PublicWeenieDesc::UnPack MOVSX behavior so ACE's FF capacity sentinels remain -1 instead of becoming 255. This suppresses non-container capacity prose through the normal retail appraisal checks, with raw-wire and formatter regression coverage.

Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
Erik 2026-07-23 18:25:17 +02:00
parent d3c5e06fdd
commit 2c00d53db2
7 changed files with 101 additions and 41 deletions

View file

@ -559,6 +559,25 @@ public sealed class CreateObjectTests
Assert.Equal(7.5f, p.Workmanship);
}
[Fact]
public void TryParse_CapacityBytes_AreSignExtendedLikeRetail()
{
byte[] body = BuildMinimalCreateObjectWithWeenieHeader(
guid: 0x50000029u,
name: "Black Phyntos Hive",
itemType: (uint)ItemType.Creature,
weenieClassId: 28249u,
weenieFlags: 0x00000002u | 0x00000004u,
itemsCapacity: -1,
containersCapacity: -1);
var parsed = CreateObject.TryParse(body);
Assert.NotNull(parsed);
Assert.Equal(-1, parsed.Value.ItemsCapacity);
Assert.Equal(-1, parsed.Value.ContainersCapacity);
}
[Fact]
public void TryParse_HookIdentityFields_AreCapturedWithoutMisaligningOverlay()
{
@ -723,8 +742,8 @@ public sealed class CreateObjectTests
ushort? burden = null,
uint weenieClassId = 0x1234,
uint? maxStackSize = null,
byte? itemsCapacity = null,
byte? containersCapacity = null,
sbyte? itemsCapacity = null,
sbyte? containersCapacity = null,
uint? container = null,
uint? wielder = null,
uint? validLocations = null,
@ -802,8 +821,10 @@ public sealed class CreateObjectTests
// its weenieFlags bit is set, matching the parser's walker exactly.
// Fields not parameterized above default to 0.
if ((weenieFlags & 0x00000001u) != 0) WriteString16L(bytes, pluralName ?? "");
if ((weenieFlags & 0x00000002u) != 0) bytes.Add(itemsCapacity ?? 0); // ItemsCapacity u8
if ((weenieFlags & 0x00000004u) != 0) bytes.Add(containersCapacity ?? 0); // ContainersCapacity u8
if ((weenieFlags & 0x00000002u) != 0)
bytes.Add(unchecked((byte)(itemsCapacity ?? 0))); // ItemsCapacity s8
if ((weenieFlags & 0x00000004u) != 0)
bytes.Add(unchecked((byte)(containersCapacity ?? 0))); // ContainersCapacity s8
if ((weenieFlags & 0x00000100u) != 0) WriteU16(bytes, ammoType ?? 0); // AmmoType u16
if ((weenieFlags & 0x00000008u) != 0) WriteU32(bytes, value ?? 0u); // Value u32
if ((weenieFlags & 0x00000010u) != 0) WriteU32(bytes, useability ?? 0u); // Usable u32