From 9c71529d8ec4c73fee0065d9bddb8d1b92073798 Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Mon, 23 Dec 2024 17:42:03 +0000 Subject: [PATCH] Add layer range check on AddLight --- KeepersCompound.LGS/Database/Chunks/WorldRep.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/KeepersCompound.LGS/Database/Chunks/WorldRep.cs b/KeepersCompound.LGS/Database/Chunks/WorldRep.cs index 1fba3a1..7ff60fc 100644 --- a/KeepersCompound.LGS/Database/Chunks/WorldRep.cs +++ b/KeepersCompound.LGS/Database/Chunks/WorldRep.cs @@ -240,9 +240,11 @@ public class WorldRep : IChunk return bytes; } - // TODO: This ONLY works for rgba (bpp = 4)!!! public void AddLight(int layer, int x, int y, float r, float g, float b) { + ArgumentOutOfRangeException.ThrowIfLessThan(layer, 0, nameof(layer)); + ArgumentOutOfRangeException.ThrowIfGreaterThan(layer, Layers, nameof(layer)); + var idx = (x + y * Width) * Bpp; var pLayer = Pixels[layer]; switch (Bpp)