diff --git a/OpenRA.Game/Graphics/CursorSequence.cs b/OpenRA.Game/Graphics/CursorSequence.cs index d5736fe9b4..8f45e548ce 100644 --- a/OpenRA.Game/Graphics/CursorSequence.cs +++ b/OpenRA.Game/Graphics/CursorSequence.cs @@ -31,7 +31,8 @@ namespace OpenRA.Graphics Palette = palette; Name = name; - Frames = cache[cursorSrc].Skip(Start).ToArray(); + var cursorSprites = cache[cursorSrc]; + Frames = cursorSprites.Skip(Start).ToArray(); if ((d.ContainsKey("Length") && d["Length"].Value == "*") || (d.ContainsKey("End") && d["End"].Value == "*")) Length = Frames.Length; @@ -44,6 +45,12 @@ namespace OpenRA.Graphics Frames = Frames.Take(Length).ToArray(); + if (Start > cursorSprites.Length) + throw new YamlException($"Cursor {name}: {nameof(Start)} is greater than the length of the sprite sequence."); + + if (Length > cursorSprites.Length) + throw new YamlException($"Cursor {name}: {nameof(Length)} is greater than the length of the sprite sequence."); + if (d.ContainsKey("X")) { Exts.TryParseIntegerInvariant(d["X"].Value, out var x);