fix(textures): DecodeSolidColor null-safe against null ColorValue
A Base1Solid (or OrigTextureId==0) Surface can carry a null ColorValue; DecodeSolidColor dereferenced it (color.Alpha) and threw NullReferenceException. It is called directly from TextureCache.DecodeFromDats, OUTSIDE DecodeRenderSurface's try/catch, so the NRE crashed the whole client. Surfaced by the D.2b chrome prove-out feeding UI surface ids. Guard null -> Magenta (the decoder's existing "undecodable" sentinel). Test added. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c9eef1d7cd
commit
66888d2c8e
2 changed files with 22 additions and 0 deletions
|
|
@ -80,6 +80,11 @@ public static class SurfaceDecoder
|
|||
/// </summary>
|
||||
public static DecodedTexture DecodeSolidColor(DatReaderWriter.Types.ColorARGB color, float translucency)
|
||||
{
|
||||
// Malformed Base1Solid (or OrigTextureId==0) surface with no color value:
|
||||
// signal undecodable (Magenta) instead of NRE. This method is called
|
||||
// directly from TextureCache.DecodeFromDats, OUTSIDE DecodeRenderSurface's
|
||||
// try/catch, so it must be null-safe itself.
|
||||
if (color is null) return DecodedTexture.Magenta;
|
||||
float opacity = Math.Clamp(1f - translucency, 0f, 1f);
|
||||
byte alpha = (byte)Math.Clamp(color.Alpha * opacity, 0f, 255f);
|
||||
return new DecodedTexture(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue