From 3c7871b352463bcc68ecd3899a7d61358661a561 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 15 May 2016 15:24:34 +0200 Subject: [PATCH] Add actor name to ease debugging of invalid bounds. --- OpenRA.Game/Primitives/SpatiallyPartitioned.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OpenRA.Game/Primitives/SpatiallyPartitioned.cs b/OpenRA.Game/Primitives/SpatiallyPartitioned.cs index 04013b9c46..8372a74fea 100644 --- a/OpenRA.Game/Primitives/SpatiallyPartitioned.cs +++ b/OpenRA.Game/Primitives/SpatiallyPartitioned.cs @@ -31,22 +31,22 @@ namespace OpenRA.Primitives itemBoundsBins = Exts.MakeArray(rows * cols, _ => new Dictionary()); } - void ValidateBounds(Rectangle bounds) + void ValidateBounds(T actor, Rectangle bounds) { if (bounds.Width == 0 || bounds.Height == 0) - throw new ArgumentException("bounds must be non-empty.", "bounds"); + throw new ArgumentException("Bounds of actor {0} are empty.".F(actor), "bounds"); } public void Add(T item, Rectangle bounds) { - ValidateBounds(bounds); + ValidateBounds(item, bounds); itemBounds.Add(item, bounds); MutateBins(item, bounds, addItem); } public void Update(T item, Rectangle bounds) { - ValidateBounds(bounds); + ValidateBounds(item, bounds); MutateBins(item, itemBounds[item], removeItem); MutateBins(item, itemBounds[item] = bounds, addItem); }