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
82 lines
3.1 KiB
C#
82 lines
3.1 KiB
C#
using Ultima;
|
|
|
|
namespace Server.Custom.Bridge
|
|
{
|
|
/// <summary>
|
|
/// **Hue application without GDI+** (servuo-plugins #39). The vendored
|
|
/// <c>Ultima.Hue.ApplyTo(Bitmap, onlyHueGrayPixels)</c> locks a 16bpp <c>Bitmap</c> and
|
|
/// repaints it in place, so the catalogue's body.def-hued creatures (162 <c>Body.def</c>
|
|
/// entries carry a non-zero hue) go back through libgdiplus after
|
|
/// <see cref="BridgeMul"/> has already escaped it. This reproduces <c>ApplyTo</c> over a
|
|
/// contiguous ARGB1555 <c>ushort[]</c> instead — same arithmetic, no <c>Bitmap</c>.
|
|
///
|
|
/// The colour table is still the vendored one: <c>Ultima.Hues.List[index].Colors</c> is a
|
|
/// <c>short[32]</c> read from <c>hues.mul</c> with no <c>System.Drawing</c>, so reusing it
|
|
/// guarantees the managed path and the vendored path tint a pixel to the identical value.
|
|
/// </summary>
|
|
public static class BridgeHue
|
|
{
|
|
/// <summary>
|
|
/// Repaints each non-transparent pixel to <c>colors[(pixel >> 10) & 0x1F]</c>
|
|
/// — the pixel's own red channel chooses the entry on the 32-step ramp, exactly as
|
|
/// <c>Hue.ApplyTo</c>. In gray-only mode only pixels whose three channels are equal are
|
|
/// touched; everything else is left alone. The buffer is contiguous (no stride), so
|
|
/// there is no row padding to skip.
|
|
/// </summary>
|
|
public static void Apply(ushort[] pixels, short[] colors, bool onlyGray)
|
|
{
|
|
if (pixels == null || colors == null)
|
|
return;
|
|
|
|
for (int i = 0; i < pixels.Length; i++)
|
|
{
|
|
int c = pixels[i];
|
|
|
|
if (c == 0)
|
|
continue;
|
|
|
|
if (onlyGray)
|
|
{
|
|
int r = (c >> 10) & 0x1F;
|
|
int g = (c >> 5) & 0x1F;
|
|
int b = c & 0x1F;
|
|
|
|
if (r == g && r == b)
|
|
pixels[i] = (ushort)colors[(c >> 10) & 0x1F];
|
|
}
|
|
else
|
|
{
|
|
pixels[i] = (ushort)colors[(c >> 10) & 0x1F];
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// The hue-object selection <c>GetAnimation</c> does (Animations.cs 474-487) before it
|
|
/// applies one: the 0x8000 bit of the raw hue is the "only gray pixels" flag, the low
|
|
/// 14 bits minus one are the <c>Hues.List</c> index, and an out-of-range index means no
|
|
/// hue at all. Returns the colour table to hand to <see cref="Apply"/>.
|
|
/// </summary>
|
|
public static bool Resolve(int rawHue, out short[] colors, out bool onlyGray)
|
|
{
|
|
colors = null;
|
|
onlyGray = (rawHue & 0x8000) != 0;
|
|
|
|
int index = (rawHue & 0x3FFF) - 1;
|
|
|
|
if (index >= 0 && index < Hues.List.Length)
|
|
{
|
|
Hue hue = Hues.List[index];
|
|
|
|
if (hue != null)
|
|
{
|
|
colors = hue.Colors;
|
|
return colors != null;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|
|
}
|