Don't crash with an unhelpful IndexOutOfRangeException.
This commit is contained in:
@@ -204,11 +204,24 @@ namespace OpenRA.Mods.Common.Graphics
|
|||||||
"{0}: Sequence {1}.{2}: Length must be <= Frames.Length"
|
"{0}: Sequence {1}.{2}: Length must be <= Frames.Length"
|
||||||
.F(info.Nodes[0].Location, sequence, animation));
|
.F(info.Nodes[0].Location, sequence, animation));
|
||||||
|
|
||||||
if (Frames == null && (Start < 0 || Start + (Facings - 1) * Stride + Length > frameCount))
|
var end = Start + (Facings - 1) * Stride + Length - 1;
|
||||||
|
if (Frames != null)
|
||||||
|
{
|
||||||
|
foreach (var f in Frames)
|
||||||
|
if (f < 0 || f >= frameCount)
|
||||||
|
throw new InvalidOperationException(
|
||||||
|
"{5}: Sequence {0}.{1} defines a Frames override that references frame {4}, but only [{2}..{3}] actually exist"
|
||||||
|
.F(sequence, animation, Start, end, f, info.Nodes[0].Location));
|
||||||
|
|
||||||
|
if (Start < 0 || end >= Frames.Length)
|
||||||
|
throw new InvalidOperationException(
|
||||||
|
"{5}: Sequence {0}.{1} uses indices [{2}..{3}] of the Frames list, but only {4} frames are defined"
|
||||||
|
.F(sequence, animation, Start, end, Frames.Length, info.Nodes[0].Location));
|
||||||
|
}
|
||||||
|
else if (Start < 0 || end >= frameCount)
|
||||||
throw new InvalidOperationException(
|
throw new InvalidOperationException(
|
||||||
"{5}: Sequence {0}.{1} uses frames [{2}..{3}], but only 0..{4} actually exist"
|
"{5}: Sequence {0}.{1} uses frames [{2}..{3}], but only 0..{4} actually exist"
|
||||||
.F(sequence, animation, Start, Start + (Facings - 1) * Stride + Length - 1, frameCount - 1,
|
.F(sequence, animation, Start, end, frameCount - 1, info.Nodes[0].Location));
|
||||||
info.Nodes[0].Location));
|
|
||||||
|
|
||||||
if (ShadowStart >= 0 && ShadowStart + (Facings - 1) * Stride + Length > frameCount)
|
if (ShadowStart >= 0 && ShadowStart + (Facings - 1) * Stride + Length > frameCount)
|
||||||
throw new InvalidOperationException(
|
throw new InvalidOperationException(
|
||||||
|
|||||||
Reference in New Issue
Block a user