# HG changeset patch # User unc0rr # Date 1567327036 -7200 # Node ID 7718bdf60d458fab302513d589edbbfd301bb7b7 # Parent 262003f2e19aaf50092ebaa010c7946bbb507453 Set dX sign early so jump calculations always get correct value diff -r 262003f2e19a -r 7718bdf60d45 hedgewars/uAIMisc.pas --- a/hedgewars/uAIMisc.pas Sat Aug 31 23:15:14 2019 +0300 +++ b/hedgewars/uAIMisc.pas Sun Sep 01 10:37:16 2019 +0200 @@ -961,6 +961,9 @@ begin HHGo:= false; Gear^.CollisionMask:= lfNotCurHogCrate; + +Gear^.dX.isNegative:= (Gear^.Message and gmLeft) <> 0; + AltGear^:= Gear^; GoInfo.Ticks:= 0; @@ -1012,21 +1015,15 @@ continue end; - // usual walk - if (Gear^.Message and gmLeft) <> 0 then - Gear^.dX:= -cLittle - else - if (Gear^.Message and gmRight) <> 0 then - Gear^.dX:= cLittle - else - exit(false); + // usual walk + Gear^.dX:= SignAs(cLittle, Gear^.dX); - if MakeHedgehogsStep(Gear) then - inc(GoInfo.Ticks, cHHStepTicks); + if MakeHedgehogsStep(Gear) then + inc(GoInfo.Ticks, cHHStepTicks); - // we have moved for 1 px - if (pX <> hwRound(Gear^.X)) and ((Gear^.State and gstMoving) = 0) then - exit(true) + // we have moved for 1 px + if (pX <> hwRound(Gear^.X)) and ((Gear^.State and gstMoving) = 0) then + exit(true) until (pX = hwRound(Gear^.X)) and (pY = hwRound(Gear^.Y)) and ((Gear^.State and gstMoving) = 0); HHJump(AltGear, jmpHJump, GoInfo);