fix(bridge): decode legacy animation art without GDI+ (#39, 1 of 2)

On a Linux/Mono shard the Asset Bridge's legacy-MUL catalogue art failed with
[GDI+ status: NotImplemented]: the vendored Ultima.Frame ctor builds a 16bpp
Bitmap (Settings.PixelFormat) and libgdiplus cannot create one. This finishes,
for the legacy animation path, the GDI+-free migration §4.4 began for UOP —
Windows and Linux now share one managed path rather than a Linux workaround.

- BridgeMul: a hand-written anim*.mul first-frame decoder to ARGB1555, mirroring
  Ultima.Frame's run loop with BridgeUop's bounds (no System.Drawing, no Bitmap).
- BridgeHue: Hue.ApplyTo reproduced over a ushort[], reusing the vendored
  Hues.List[i].Colors table so a body.def-hued creature tints identically.
- BridgeAssetValidator: RecordReader.ReadRecordCopy hands the verdata-patched
  record bytes to the managed decoder; a ResolveAnimation overload surfaces the
  body.def hue it already computes and discarded.
- BridgeCatalog: the legacy path now decodes through BridgeMul + BridgeHue ->
  BridgePng; the imaging gate is removed from assets.manifest/fetch, since the
  body catalogue (legacy + UOP) no longer touches System.Drawing. The record
  gate (ResolveAnimation/CheckEntry/AnimationSane) is unchanged.
- BridgeAnimParity: a [BridgeAnimParity] GM command / BRIDGE_ANIM_PARITY=1 boot
  run that compares the managed decode against the vendored one pixel for pixel.

Overlay-only; no wire change, no PROTOCOL_VERSION bump. The art/land path
(BridgeArt) and its imaging gate are the second PR. The art family's imaging.ok
status is unchanged meanwhile.

Verified on this machine's ServUO + live client: the parity harness compared all
40,341 records the Bridge serves and every one is pixel-identical to the vendored
GDI+ decode (0 mismatched, 0 missed); 102,923 out-of-band/invalid records the
Bridge refuses were correctly skipped.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014HJEmcaKvWQ8LsnXHKha5y
This commit is contained in:
2026-11-25 21:12:24 -06:00
parent 3d71c9ac2d
commit 5dd5780f42
5 changed files with 841 additions and 88 deletions

View File

@@ -361,10 +361,25 @@ namespace Server.Custom.Bridge
/// </summary>
public static bool ResolveAnimation(
int body, int action, int direction, out int fileType, out int index, out string reason)
{
int hue;
return ResolveAnimation(body, action, direction, out fileType, out index, out hue, out reason);
}
/// <summary>
/// As above, and also surfaces the hue <c>GetAnimation(..., preserveHue: false, ...)</c>
/// would apply. <c>Animations.Translate(ref body, ref hue)</c> pulls a body.def remap's
/// hue into <paramref name="hue"/> (0 for a body that is not a hued remap); the legacy
/// catalogue decode needs it so a managed, GDI+-free path tints the same creatures the
/// vendored path tinted on Windows.
/// </summary>
public static bool ResolveAnimation(
int body, int action, int direction, out int fileType, out int index, out int hue, out string reason)
{
reason = null;
fileType = 0;
index = -1;
hue = 0;
if (body <= 0 || action < 0)
{
@@ -383,7 +398,6 @@ namespace Server.Custom.Bridge
}
int translated = body;
int hue = 0;
try
{
@@ -801,6 +815,25 @@ namespace Server.Custom.Bridge
return AnimationRecordSane(_scratch, length, maxFrames, out reason);
}
/// <summary>
/// One record as its own byte[] — the verdata-patched bytes <see cref="ReadRecord"/>
/// validates — for a managed decoder (<see cref="BridgeMul"/>) to read without GDI+.
/// A fresh copy rather than the shared scratch buffer, because the caller holds it
/// across its whole decode and the next read would overwrite it. Null when there is
/// nothing to read or the read fails (<paramref name="reason"/> set on a failure).
/// </summary>
public byte[] ReadRecordCopy(FileIndex index, int at, out string reason)
{
int length = ReadRecord(index, at, out reason);
if (length <= 0)
return null;
var copy = new byte[length];
Buffer.BlockCopy(_scratch, 0, copy, 0, length);
return copy;
}
/// <summary>
/// Reads one record into <see cref="_scratch"/>. Returns its length, 0 for a
/// failure (with <paramref name="reason"/> set), or -1 when there is nothing to