hedgewars/uGearsHandlersMess.pas
changeset 11070 f9a03078dd4f
parent 11057 adb5ef54da54
child 11152 3ac7f6d43200
--- a/hedgewars/uGearsHandlersMess.pas	Thu Sep 03 09:00:26 2015 -0400
+++ b/hedgewars/uGearsHandlersMess.pas	Thu Sep 03 11:51:08 2015 -0400
@@ -2807,11 +2807,12 @@
     HHGear: PGear;
 begin
     HHGear := Gear^.Hedgehog^.Gear;
-    doStepHedgehogMoving(HHGear);
+    if HHGear <> nil then doStepHedgehogMoving(HHGear);
     // if not infattack mode wait for hedgehog finish falling to collect cases
     if ((GameFlags and gfInfAttack) <> 0)
+    or (HHGear = nil)
     or ((HHGear^.State and gstMoving) = 0)
-    or (Gear^.Hedgehog^.Gear^.Damage > 0)
+    or (HHGear^.Damage > 0)
     or ((HHGear^.State and gstDrowning) = 1) then
         begin
         DeleteGear(Gear);
@@ -2821,7 +2822,7 @@
 
 procedure doStepTeleportAnim(Gear: PGear);
 begin
-    if (Gear^.Hedgehog^.Gear^.Damage > 0) then
+    if (Gear^.Hedgehog^.Gear = nil) or (Gear^.Hedgehog^.Gear^.Damage > 0) then
         begin
         DeleteGear(Gear);
         AfterAttack;
@@ -2848,6 +2849,11 @@
     AllInactive := false;
 
     HHGear := Gear^.Hedgehog^.Gear;
+    if HHGear = nil then
+    begin
+        DeleteGear(Gear);
+        exit
+    end; 
 
     valid:= false;