diff --git a/OpenRA.Game/WPos.cs b/OpenRA.Game/WPos.cs index 369aca6bab..0966d6c849 100644 --- a/OpenRA.Game/WPos.cs +++ b/OpenRA.Game/WPos.cs @@ -64,8 +64,8 @@ namespace OpenRA return ret; // Add an additional quadratic variation to height - // Attempts to avoid integer overflow by keeping the intermediate variables reasonably sized - var offset = (int)(((((((long)(b - a).Length * mul) / div) * (div - mul)) / div) * pitch.Tan()) / 1024); + // Uses decimal to avoid integer overflow + var offset = (int)((decimal)(b - a).Length * pitch.Tan() * mul * (div - mul) / (1024 * div * div)); return new WPos(ret.X, ret.Y, ret.Z + offset); }