Add layer range check on AddLight

This commit is contained in:
Jarrod Doyle 2024-12-23 17:42:03 +00:00
parent e3aac88c17
commit 9c71529d8e
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
1 changed files with 3 additions and 1 deletions

View File

@ -240,9 +240,11 @@ public class WorldRep : IChunk
return bytes; 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) 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 idx = (x + y * Width) * Bpp;
var pLayer = Pixels[layer]; var pLayer = Pixels[layer];
switch (Bpp) switch (Bpp)