isZero appears to be never used. Use it in a few obvious cases and add web variant.
authornemo
Wed, 29 Aug 2012 09:58:23 -0400
changeset 7623 addc5b262617
parent 7622 172fb1c7615b
child 7624 03d662ff9c41
isZero appears to be never used. Use it in a few obvious cases and add web variant.
hedgewars/GSHandlers.inc
hedgewars/uFloat.pas
hedgewars/uGearsHedgehog.pas
--- a/hedgewars/GSHandlers.inc	Wed Aug 29 16:42:22 2012 +0400
+++ b/hedgewars/GSHandlers.inc	Wed Aug 29 09:58:23 2012 -0400
@@ -1483,7 +1483,7 @@
     or TestCollisionXwithGear(Gear, -2) 
     or (TestCollisionYwithGear(Gear, 2) <> 0) then
         begin
-        if (hwAbs(Gear^.dX) > _0) or (hwAbs(Gear^.dY) > _0) then
+        if (not isZero(Gear^.dX)) or (not isZero(Gear^.dY)) then
             begin
             PlaySound(sndRopeAttach);
             Gear^.dX:= _0;
--- a/hedgewars/uFloat.pas	Wed Aug 29 16:42:22 2012 +0400
+++ b/hedgewars/uFloat.pas	Wed Aug 29 09:58:23 2012 -0400
@@ -269,6 +269,11 @@
     z.QWordValue:= z1.QWordValue + z2.QWordValue
     end
 end;
+
+function isZero(const z: hwFloat): boolean; inline; 
+begin
+isZero := z.QWordValue = 0;
+end;
 {$ENDIF}
 {$IFDEF WEB}
 (*
@@ -343,6 +348,11 @@
     if z.Frac<z1.Frac then inc(z.Round)
     end
 end;
+
+function isZero(const z: hwFloat): boolean; inline; 
+begin
+isZero := z.Round = 0 and z.Frac = 0;
+end;
 {$ENDIF}
 
 operator - (const z1: hwFloat) z : hwFloat;
@@ -544,11 +554,6 @@
 else
     AngleCos.QWordValue:= SinTable[Angle - 1024]
 end;
-
-function isZero(const z: hwFloat): boolean; inline; 
-begin
-isZero := z.QWordValue = 0;
-end;
 {$ENDIF}
 
 end.
--- a/hedgewars/uGearsHedgehog.pas	Wed Aug 29 16:42:22 2012 +0400
+++ b/hedgewars/uGearsHedgehog.pas	Wed Aug 29 09:58:23 2012 -0400
@@ -1014,8 +1014,8 @@
         if (CurrentHedgehog^.Gear = Gear) then
             isCursorVisible:= false
     end;
-
-if (hwAbs(Gear^.dY) > _0) and (Gear^.FlightTime > 0) and ((GameFlags and gfLowGravity) = 0) then
+// IMO this should trigger homerun based on leftX/rightX + someval instead - that is 'knocking it out of the park'
+if (not isZero(Gear^.dY)) and (Gear^.FlightTime > 0) and ((GameFlags and gfLowGravity) = 0) then
     begin
     inc(Gear^.FlightTime);
     if Gear^.FlightTime = 3000 then