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
|
|
@ -0,0 +1,17 @@
|
|||
using AcDream.Core.Textures;
|
||||
using Xunit;
|
||||
|
||||
namespace AcDream.Core.Tests.Textures;
|
||||
|
||||
public class SurfaceDecoderSolidColorTests
|
||||
{
|
||||
[Fact]
|
||||
public void DecodeSolidColor_NullColor_ReturnsMagenta_DoesNotThrow()
|
||||
{
|
||||
// A malformed Base1Solid surface can carry a null ColorValue. DecodeSolidColor
|
||||
// is called outside DecodeRenderSurface's try/catch (from TextureCache), so it
|
||||
// must be null-safe itself — return the undecodable sentinel, never NRE.
|
||||
var result = SurfaceDecoder.DecodeSolidColor(null!, 0f);
|
||||
Assert.Equal(DecodedTexture.Magenta, result);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue