From 3b1e4d708ddf2ef5f27daa96ea55e90c53832d09 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Fri, 2 Sep 2016 19:57:32 +0100 Subject: [PATCH] Fix an off-by-one error in NormalizeFacing. --- OpenRA.Mods.Common/Util.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Util.cs b/OpenRA.Mods.Common/Util.cs index 54a3ccc538..e0a06a46ed 100644 --- a/OpenRA.Mods.Common/Util.cs +++ b/OpenRA.Mods.Common/Util.cs @@ -73,12 +73,14 @@ namespace OpenRA.Mods.Common } } + /// Wraps an arbitrary integer facing value into the range 0 - 255 public static int NormalizeFacing(int f) { if (f >= 0) return f & 0xFF; - return 0xFF - (-f & 0xFF); + var negative = -f & 0xFF; + return negative == 0 ? 0 : 256 - negative; } public static WPos BetweenCells(World w, CPos from, CPos to)