Fix parachute moving hog very fast or making it stuck when bumping into wall while facing the opposite direction (bug 742)
authorWuzzy <Wuzzy2@mail.ru>
Tue, 14 May 2019 02:29:29 +0200
changeset 14936 d6a8ef85cf53
parent 14935 4accf3e18dbc
child 14937 896707084562
Fix parachute moving hog very fast or making it stuck when bumping into wall while facing the opposite direction (bug #742)
ChangeLog.txt
hedgewars/uGearsHandlersMess.pas
--- a/ChangeLog.txt	Tue May 14 01:10:02 2019 +0200
+++ b/ChangeLog.txt	Tue May 14 02:29:29 2019 +0200
@@ -19,6 +19,7 @@
  * Deny placement of piano beyond bounce world edge
  * Fix cut scenes not being skipped when pressing precise in enemy turn
  * Fix laser sight not working properly when it starts out of map bounds
+ * Fix parachute making hog stuck or fast when bumping into wall while looking other way
  * Add missing winner animation in single missions
 
 Styles and schemes:
--- a/hedgewars/uGearsHandlersMess.pas	Tue May 14 01:10:02 2019 +0200
+++ b/hedgewars/uGearsHandlersMess.pas	Tue May 14 02:29:29 2019 +0200
@@ -2929,6 +2929,7 @@
 procedure doStepParachuteWork(Gear: PGear);
 var
     HHGear: PGear;
+    deltaX: hwFloat;
 begin
     HHGear := Gear^.Hedgehog^.Gear;
 
@@ -2954,13 +2955,14 @@
         exit
         end;
 
-    HHGear^.X := HHGear^.X + cWindSpeed * 200;
+    deltaX:= _0;
+    deltaX:= deltaX + cWindSpeed * 200;
 
     if (Gear^.Message and gmLeft) <> 0 then
-        HHGear^.X := HHGear^.X - cMaxWindSpeed * 80
+        deltaX := deltaX - cMaxWindSpeed * 80
 
     else if (Gear^.Message and gmRight) <> 0 then
-        HHGear^.X := HHGear^.X + cMaxWindSpeed * 80;
+        deltaX := deltaX + cMaxWindSpeed * 80;
 
     if (Gear^.Message and gmUp) <> 0 then
         HHGear^.Y := HHGear^.Y - cGravity * 40
@@ -2968,9 +2970,10 @@
     else if (Gear^.Message and gmDown) <> 0 then
         HHGear^.Y := HHGear^.Y + cGravity * 40;
 
+    HHGear^.X := HHGear^.X + deltaX;
     // don't drift into obstacles
-    if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) <> 0 then
-        HHGear^.X := HHGear^.X - int2hwFloat(hwSign(HHGear^.dX));
+    if TestCollisionXwithGear(HHGear, hwSign(deltaX)) <> 0 then
+        HHGear^.X := HHGear^.X - int2hwFloat(hwSign(deltaX));
     HHGear^.Y := HHGear^.Y + cGravity * 100;
     Gear^.X := HHGear^.X;
     Gear^.Y := HHGear^.Y