Fix floating hog when switching to moving hog
authorWuzzy <Wuzzy2@mail.ru>
Tue, 11 Jun 2019 16:02:29 +0200
changeset 15155 0e0b5fc1674e
parent 15154 73d8cc72239e
child 15156 7a8cc8bc963e
Fix floating hog when switching to moving hog
ChangeLog.txt
hedgewars/uGearsHandlersMess.pas
--- a/ChangeLog.txt	Sat Jun 08 11:29:49 2019 +0200
+++ b/ChangeLog.txt	Tue Jun 11 16:02:29 2019 +0200
@@ -33,6 +33,7 @@
  * 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
+ * Fix hog floating when switching to moving hog
 
 Styles and schemes:
  + The Specialists: Unlock game scheme
--- a/hedgewars/uGearsHandlersMess.pas	Sat Jun 08 11:29:49 2019 +0200
+++ b/hedgewars/uGearsHandlersMess.pas	Tue Jun 11 16:02:29 2019 +0200
@@ -3369,9 +3369,9 @@
         exit
         end;
 
+    HHGear := CurrentHedgehog^.Gear;
     if (Gear^.Message and gmSwitch) <> 0 then
         begin
-        HHGear := CurrentHedgehog^.Gear;
         oldUid:= HHGear^.uid;
         HHGear^.Message := HHGear^.Message and (not gmSwitch);
         Gear^.Message := Gear^.Message and (not gmSwitch);
@@ -3386,9 +3386,10 @@
             switchDir:=  1;
 
         State := HHGear^.State;
-        HHGear^.State := 0;
+        if (HHGear^.State and gstMoving) = 0 then
+            HHGear^.Active := false;
+        HHGear^.State := HHGear^.State and gstMoving;
         HHGear^.Z := cHHZ;
-        HHGear^.Active := false;
         HHGear^.Message:= HHGear^.Message or gmRemoveFromList or gmAddToList;
 
         PlaySound(sndSwitchHog);
@@ -3414,9 +3415,10 @@
         if (switchDir <> 1) then
             HHGear^.Message:= HHGear^.Message or gmPrecise;
         HHGear^.Message:= HHGear^.Message or gmRemoveFromList or gmAddToList;
-        Gear^.X := HHGear^.X;
-        Gear^.Y := HHGear^.Y
-        end;
+        end;
+    doStepHedgehogMoving(HHGear);
+    Gear^.X := HHGear^.X;
+    Gear^.Y := HHGear^.Y
 end;
 
 procedure doStepSwitcher(Gear: PGear);