From 9b3ddee5173890d6458d91acc4f7996de4d69b8e Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sun, 23 Dec 2018 21:29:50 +1300 Subject: [PATCH] Fix QuantizeFacing returning values >= numFacings. --- OpenRA.Mods.Common/Util.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Util.cs b/OpenRA.Mods.Common/Util.cs index 9a007dbcb0..30bf469657 100644 --- a/OpenRA.Mods.Common/Util.cs +++ b/OpenRA.Mods.Common/Util.cs @@ -49,8 +49,10 @@ namespace OpenRA.Mods.Common public static int QuantizeFacing(int facing, int numFrames) { var step = 256 / numFrames; - var a = (facing + step / 2) & 0xff; - return a / step; + var f = NormalizeFacing(facing + step / 2) / step; + + // f may be >= numFrames so wrap it back in range + return f % numFrames; } public static int QuantizeFacing(int facing, int numFrames, bool useClassicFacingFudge)