limit Y increment to 6 (saucer/birdy bug)
authornemo
Tue, 05 Jan 2016 15:15:54 -0500
changeset 11484 cb64affd7715
parent 11483 dbc0d54798dc
child 11485 e5bc40acdfaa
limit Y increment to 6 (saucer/birdy bug)
hedgewars/uGearsHedgehog.pas
--- a/hedgewars/uGearsHedgehog.pas	Mon Jan 04 10:08:26 2016 +0300
+++ b/hedgewars/uGearsHedgehog.pas	Tue Jan 05 15:15:54 2016 -0500
@@ -876,6 +876,7 @@
 procedure doStepHedgehogMoving(Gear: PGear);
 var isFalling, isUnderwater: boolean;
     land: Word;
+    cnt: LongWord;
 begin
 if Gear^.Hedgehog^.Unplaced then
     begin
@@ -1037,15 +1038,24 @@
                         else
                             begin
                             Gear^.State:= Gear^.State and (not gstMoving);
-                            while TestCollisionYWithGear(Gear,1) = 0 do
-                                Gear^.Y:= Gear^.Y+_1;
+                            cnt:= 0;
+                            while (cnt < 6) and (not CheckGearDrowning(Gear)) and (Gear <> nil) and (TestCollisionYWithGear(Gear,1) = 0) do
+                                begin
+                                Gear^.Y:= Gear^.Y + _1;
+                                inc(cnt)
+                                end;
+
                             SetLittle(Gear^.dX)
                             end
             else
                 begin
                 Gear^.State:= Gear^.State and (not gstMoving);
-                while TestCollisionYWithGear(Gear,1) = 0 do
-                    Gear^.Y:= Gear^.Y+_1;
+                cnt:= 0;
+                while (cnt < 6) and (not CheckGearDrowning(Gear)) and (Gear <> nil) and (TestCollisionYWithGear(Gear,1) = 0) do
+                    begin
+                    Gear^.Y:= Gear^.Y + _1;
+                    inc(cnt)
+                    end;
                 SetLittle(Gear^.dX)
                 end
         else if (hwAbs(Gear^.dX) > cLittle)
@@ -1059,8 +1069,12 @@
     begin
     Gear^.State:= Gear^.State and (not gstWinner);
     Gear^.State:= Gear^.State and (not gstMoving);
-    while (not CheckGearDrowning(Gear)) and (Gear <> nil) and (TestCollisionYWithGear(Gear,1) = 0) do
+    cnt:= 0;
+    while (cnt < 6) and (not CheckGearDrowning(Gear)) and (Gear <> nil) and (TestCollisionYWithGear(Gear,1) = 0) do
+        begin
         Gear^.Y:= Gear^.Y + _1;
+        inc(cnt)
+        end;
 
     // could become nil in CheckGearDrowning if ai's hog fails to respawn in ai survival
     if Gear = nil then exit;