Add nil checks on HHGear to rope steps.
authornemo
Tue, 16 Dec 2014 14:23:24 -0500
changeset 10681 474d418a34c5
parent 10679 5989c293955a
child 10682 1be106f8095a
Add nil checks on HHGear to rope steps.
hedgewars/uGearsHandlersRope.pas
--- a/hedgewars/uGearsHandlersRope.pas	Tue Dec 16 08:04:18 2014 -0500
+++ b/hedgewars/uGearsHandlersRope.pas	Tue Dec 16 14:23:24 2014 -0500
@@ -34,6 +34,12 @@
     tX:     hwFloat;
 begin
     HHGear := Gear^.Hedgehog^.Gear;
+    if HHGear = nil then
+        begin
+        DeleteGear(Gear);
+        exit()
+        end;
+
     tX:= HHGear^.X;
     if WorldWrap(HHGear) and (WorldEdge = weWrap) and
        ((TestCollisionXwithGear(HHGear, 1) <> 0) or (TestCollisionXwithGear(HHGear, -1) <> 0))  then
@@ -124,6 +130,11 @@
     if GameTicks mod 4 <> 0 then exit;
 
     HHGear := Gear^.Hedgehog^.Gear;
+    if HHGear = nil then
+        begin
+        DeleteGear(Gear);
+        exit()
+        end;
 
     tX:= HHGear^.X;
     if WorldWrap(HHGear) and (WorldEdge = weWrap) and
@@ -414,6 +425,12 @@
     Gear^.Elasticity := Gear^.Elasticity + _1;
 
     HHGear := Gear^.Hedgehog^.Gear;
+    if HHGear = nil then
+        begin
+        DeleteGear(Gear);
+        exit()
+        end;
+
     DeleteCI(HHGear);
 
     if (HHGear^.State and gstMoving) <> 0 then