From f5b749e9ce185bba728cff4fbe3bc41f7b8f2f27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Tue, 1 Jul 2014 11:50:28 +0200 Subject: [PATCH] fix a rounding problem in SHP(TS) offset floating point math closes #5765 --- OpenRA.Game/FileFormats/ShpTSReader.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OpenRA.Game/FileFormats/ShpTSReader.cs b/OpenRA.Game/FileFormats/ShpTSReader.cs index f5200947c7..661a2790f4 100644 --- a/OpenRA.Game/FileFormats/ShpTSReader.cs +++ b/OpenRA.Game/FileFormats/ShpTSReader.cs @@ -33,7 +33,8 @@ namespace OpenRA.FileFormats var width = stream.ReadUInt16(); var height = stream.ReadUInt16(); - Offset = new float2(x + 0.5f * (width - frameSize.Width), y + 0.5f * (height - frameSize.Height)); + // Note: the mixed Integer / fp division is intentional, and required for calculating the correct offset. + Offset = new float2(x + width / 2 - 0.5f * frameSize.Width, y + height / 2 - 0.5f * frameSize.Height); Size = new Size(width, height); FrameSize = frameSize;