Fix cake rotation angle after bounce from bounce edge
authorWuzzy <Wuzzy2@mail.ru>
Mon, 06 Aug 2018 15:20:25 +0200
changeset 13613 92b87845beeb
parent 13612 212036414957
child 13614 13f68f3e7153
Fix cake rotation angle after bounce from bounce edge
hedgewars/uGearsHandlersMess.pas
--- a/hedgewars/uGearsHandlersMess.pas	Fri Aug 03 00:39:50 2018 +0200
+++ b/hedgewars/uGearsHandlersMess.pas	Mon Aug 06 15:20:25 2018 +0200
@@ -3535,6 +3535,7 @@
 var
     tdx, tdy: hwFloat;
     cakeData: PCakeData;
+    i: Longword;
 begin
     AllInactive := false;
 
@@ -3566,12 +3567,26 @@
         Gear^.WDTimer := 0;
         Gear^.Angle := (LongInt(Gear^.Angle) + 2) and 3;
         Gear^.Karma := 0;
+
+        // Reset CakePoints to fix cake angle
+        cakeData:= PCakeData(Gear^.Data);
+        with cakeData^ do
+            begin
+            for i:= 0 to Pred(cakeh) do
+                begin
+                CakePoints[i].x := Gear^.X;
+                CakePoints[i].y := Gear^.Y;
+                end;
+                CakeI:= 0;
+            end;
+        Gear^.Tag:= 0;
         end
     else if (Gear^.Karma = 2) then
         begin
-        // Cake doesn't know how walk through world wrap
-        // so it gives up and stops.
-        // TODO: Teach cake how to deal with world wrap.
+        (* Cake passed world edge.
+        Cake doesn't know yet how walk through
+        world wrap so it gives up and stops.
+        TODO: Teach cake how to deal with world wrap. *)
         Gear^.Health := 0;
         Gear^.Karma := 0;
         end;