# HG changeset patch # User unc0rr # Date 1366403212 -14400 # Node ID e5db2a42e7e8644cc98e44164be0f72b2bbd337d # Parent caa614af152ddd8cd28262c4e14799a014b0b1b1 - Revert division hack nonsense - Patch Distance instead to not produce zero on non-zero parameters passed diff -r caa614af152d -r e5db2a42e7e8 hedgewars/uFloat.pas --- a/hedgewars/uFloat.pas Thu Apr 18 21:25:38 2013 +0400 +++ b/hedgewars/uFloat.pas Sat Apr 20 00:26:52 2013 +0400 @@ -315,7 +315,6 @@ operator / (const z1: hwFloat; z2: hwFloat) z : hwFloat; inline; var t: QWord; begin -if z2.QWordValue = 0 then inc(z2.QWordValue); z.isNegative:= z1.isNegative xor z2.isNegative; z.Round:= z1.QWordValue div z2.QWordValue; t:= z1.QWordValue - z2.QWordValue * z.Round; @@ -328,7 +327,7 @@ t:= t shl 8; z2.QWordValue:= z2.QWordValue shl 8 end; - + if z2.Round > 0 then inc(z.QWordValue, t div z2.Round); end @@ -457,8 +456,16 @@ function Distance(const dx, dy: hwFloat): hwFloat; +var r: QWord; begin -Distance:= hwSqrt(hwSqr(dx) + hwSqr(dy)) +r:= dx.QWordValue or dy.QWordValue; + +if r < $10000 then + begin + Distance.QWordValue:= r; + Distance.isNegative:= false + end else + Distance:= hwSqrt(hwSqr(dx) + hwSqr(dy)) end; function DistanceI(const dx, dy: LongInt): hwFloat;