Fix an off-by-one error in NormalizeFacing.

This commit is contained in:
Paul Chote
2016-09-02 19:57:32 +01:00
parent cb7f6947d1
commit 3b1e4d708d

View File

@@ -73,12 +73,14 @@ namespace OpenRA.Mods.Common
}
}
/// <summary>Wraps an arbitrary integer facing value into the range 0 - 255</summary>
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)