fix(colours): text the game colours without an alpha byte rendered invisible

The game hands out some of its configured colours as ARGB with the alpha
byte left at zero. The byte swap then moved that zero into the alpha slot
and the text drew fully transparent.

Two guards, and they belong together: forcing alpha on a colour that is
zero everywhere would turn "no colour" into opaque black, which slips
past the invisible-text fallback in ChunkUtil and paints over the colour
the renderer would otherwise inherit.
This commit is contained in:
2026-08-20 07:54:19 +02:00
parent 6e24885241
commit d5c7db9f43
+15
View File
@@ -66,8 +66,23 @@ internal static class ColourUtil
); );
} }
// ---------------------------------------------------------------
// Cherry-picked from ChatTwo upstream a51789b + 5b58513 (Infiziert90,
// 2026-06-12). Both guards belong together -- a51789b alone turns a zero
// colour into opaque black, which then slips past the invisible-text
// guard in ChunkUtil and paints over the inherited colour.
// TEST-MIRROR: ../../../Hellion Build test/Util/ColourUtilTests.cs
// ---------------------------------------------------------------
public static unsafe uint ArgbToRgba(uint x) public static unsafe uint ArgbToRgba(uint x)
{ {
if (x == 0)
return 0;
// The game omits the alpha byte on some GlobalValue colours, and the
// swap below would leave alpha at 0 -- invisible text.
if (x <= 0x00FFFFFFu)
x |= 0xFF000000u;
var buf = (byte*)&x; var buf = (byte*)&x;
(buf[1], buf[2], buf[3], buf[0]) = (buf[0], buf[1], buf[2], buf[3]); (buf[1], buf[2], buf[3], buf[0]) = (buf[0], buf[1], buf[2], buf[3]);
return x; return x;