hedgewars/uGearsList.pas
changeset 10874 059a6492176e
parent 10848 231d3e3d3267
child 10875 67b92a09cded
--- a/hedgewars/uGearsList.pas	Tue Mar 24 21:18:05 2015 +0100
+++ b/hedgewars/uGearsList.pas	Wed Mar 25 20:30:52 2015 +0100
@@ -166,6 +166,7 @@
 function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
 var gear: PGear;
     //c: byte;
+    cakeData: PCakeData;
 begin
 inc(GCounter);
 
@@ -193,6 +194,7 @@
 gear^.AmmoType:= GearKindAmmoTypeMap[Kind];
 gear^.CollisionMask:= $FFFF;
 gear^.Tint:= $FFFFFFFF;
+gear^.Data:= nil;
 
 if CurrentHedgehog <> nil then
     begin
@@ -507,7 +509,9 @@
                 if not dX.isNegative then
                     gear^.Angle:= 1
                 else
-                    gear^.Angle:= 3
+                    gear^.Angle:= 3;
+                New(cakeData);
+                gear^.Data:= Pointer(cakeData);
                 end;
  gtHellishBomb: begin
                 gear^.ImpactSound:= sndHellishImpact1;
@@ -660,6 +664,7 @@
 var team: PTeam;
     t,i: Longword;
     k: boolean;
+    cakeData: PCakeData;
 begin
 
 ScriptCall('onGearDelete', gear^.uid);
@@ -675,6 +680,12 @@
         if (Gear^.LinkedGear^.LinkedGear = Gear) then
             Gear^.LinkedGear^.LinkedGear:= nil;
     end
+else if Gear^.Kind = gtCake then
+    begin
+        cakeData:= PCakeData(Gear^.Data);
+        Dispose(cakeData);
+        cakeData:= nil;
+    end
 else if Gear^.Kind = gtHedgehog then
     (*
     This behaviour dates back to revision 4, and I accidentally encountered it with TARDIS.  I don't think it must apply to any modern weapon, since if it was actually hit, the best the gear could do would be to destroy itself immediately, and you'd still end up with two graves.  I believe it should be removed