hedgewars/uAIMisc.pas
changeset 15410 7718bdf60d45
parent 15387 381c828865e7
child 15631 308930fe5f4a
--- 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);