# HG changeset patch # User alfadur # Date 1594251711 -10800 # Node ID 73c4e7d47575b063687ef0105fa65d3f91a0f26a # Parent b496233ac26d10f092111c7bd18587b6e111acd6 fix sentry left jump diff -r b496233ac26d -r 73c4e7d47575 hedgewars/uGearsHandlersMess.pas --- a/hedgewars/uGearsHandlersMess.pas Thu Jul 09 00:45:27 2020 +0300 +++ b/hedgewars/uGearsHandlersMess.pas Thu Jul 09 02:41:51 2020 +0300 @@ -7202,29 +7202,29 @@ end; function MakeSentryJump(Sentry: PGear; maxXStep, maxYStep: LongInt): Boolean; -var x, y, offsetX, offsetY: LongInt; +var x, y, offsetX, offsetY, direction: LongInt; jumpTime: hwFloat; begin MakeSentryJump := false; x := hwRound(Sentry^.X); y := hwRound(Sentry^.Y); - offsetX := (maxXStep - Sentry^.Radius) * hwSign(Sentry^.dX); + offsetX := maxXStep - Sentry^.Radius; + direction := hwSign(Sentry^.dX); + repeat for offsetY := -maxYStep - 1 to maxYStep + 1 do - begin - if TestCollisionYImpl(x + offsetX, y + offsetY, Sentry^.Radius, 1, Sentry^.CollisionMask) <> 0 then + if TestCollisionYImpl(x + offsetX * direction, y + offsetY, Sentry^.Radius, 1, Sentry^.CollisionMask) <> 0 then break; - end; if (offsetY >= -maxYStep) and (offsetY <= maxYStep) then break; - Dec(offsetX, Sentry^.Radius * hwSign(Sentry^.dX)); + Dec(offsetX, Sentry^.Radius); until offsetX <= 0; - if (offsetX > 0) and (not cGravity.isNegative) then + if (offsetX >= Sentry^.Radius) and (not cGravity.isNegative) then begin Sentry^.dY := -_0_25; jumpTime := _2 * Sentry^.dY / cGravity; - Sentry^.dX := SignAs(int2hwFloat(abs(offsetX) - Sentry^.Radius) / jumpTime, Sentry^.dX); + Sentry^.dX := SignAs(int2hwFloat(offsetX - Sentry^.Radius) / jumpTime, Sentry^.dX); MakeSentryJump := true; end; end;