# HG changeset patch # User nemo # Date 1346248703 14400 # Node ID addc5b2626174ae57e72982db1f6a8a3af45f9bc # Parent 172fb1c7615b70384bdee46296d6049eb0c2adb4 isZero appears to be never used. Use it in a few obvious cases and add web variant. diff -r 172fb1c7615b -r addc5b262617 hedgewars/GSHandlers.inc --- 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; diff -r 172fb1c7615b -r addc5b262617 hedgewars/uFloat.pas --- 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. diff -r 172fb1c7615b -r addc5b262617 hedgewars/uGearsHedgehog.pas --- 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