Add some HHGear nil checks to teleport. google bug #974
authornemo
Thu, 03 Sep 2015 11:51:08 -0400
changeset 11070 f9a03078dd4f
parent 11069 1997662b68d8
child 11071 3851ce4f2061
child 11072 532141feeebf
Add some HHGear nil checks to teleport. google bug #974
hedgewars/uGearsHandlersMess.pas
--- 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;