Merge pull request #11821 from UnknownProgrammer/patch-1

Fix for System Overflow exception
This commit is contained in:
reaperrr
2016-09-18 13:12:59 +02:00
committed by GitHub

View File

@@ -65,8 +65,10 @@ namespace OpenRA
// Add an additional quadratic variation to height
// 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);
var offset = (decimal)(b - a).Length * pitch.Tan() * mul * (div - mul) / (1024 * div * div);
var clampedOffset = (int)(offset + (decimal)ret.Z).Clamp<decimal>((decimal)int.MinValue, (decimal)int.MaxValue);
return new WPos(ret.X, ret.Y, clampedOffset);
}
public override int GetHashCode() { return X.GetHashCode() ^ Y.GetHashCode() ^ Z.GetHashCode(); }