- Revert division hack nonsense
authorunc0rr
Sat, 20 Apr 2013 00:26:52 +0400
changeset 8921 e5db2a42e7e8
parent 8920 caa614af152d
child 8923 2dfe7c57667c
- Revert division hack nonsense - Patch Distance instead to not produce zero on non-zero parameters passed
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;