hedgewars/uGearsHandlersRope.pas
changeset 10684 d403fd2f9a6f
parent 10680 4a4a82686e91
parent 10681 474d418a34c5
child 10722 37264e44ec0f
--- a/hedgewars/uGearsHandlersRope.pas	Tue Dec 16 22:30:17 2014 +0100
+++ b/hedgewars/uGearsHandlersRope.pas	Tue Dec 16 23:41:26 2014 +0100
@@ -28,12 +28,22 @@
 uses uConsts, uFloat, uCollisions, uVariables, uGearsList, uSound, uGearsUtils,
     uAmmos, uDebug, uUtils, uGearsHedgehog, uGearsRender;
 
+const
+    IsNilHHFatal = true;
+
 procedure doStepRopeAfterAttack(Gear: PGear);
 var
     HHGear: PGear;
     tX:     hwFloat;
 begin
     HHGear := Gear^.Hedgehog^.Gear;
+    if HHGear = nil then
+        begin
+        OutError('ERROR: doStepRopeAfterAttack called while HHGear = nil', IsNilHHFatal);
+        DeleteGear(Gear);
+        exit()
+        end;
+
     tX:= HHGear^.X;
     if WorldWrap(HHGear) and (WorldEdge = weWrap) and
        ((TestCollisionXwithGear(HHGear, 1) <> 0) or (TestCollisionXwithGear(HHGear, -1) <> 0))  then
@@ -122,6 +132,12 @@
     wrongSide: boolean;
 begin
     HHGear := Gear^.Hedgehog^.Gear;
+    if HHGear = nil then
+        begin
+        OutError('ERROR: doStepRopeWork called while HHGear = nil', IsNilHHFatal);
+        DeleteGear(Gear);
+        exit()
+        end;
 
     if ((HHGear^.State and gstHHDriven) = 0) or
         (CheckGearDrowning(HHGear)) or (Gear^.PortalCounter <> 0) then
@@ -414,6 +430,13 @@
     Gear^.Elasticity := Gear^.Elasticity + _1;
 
     HHGear := Gear^.Hedgehog^.Gear;
+    if HHGear = nil then
+        begin
+        OutError('ERROR: doStepRopeAttach called while HHGear = nil', IsNilHHFatal);
+        DeleteGear(Gear);
+        exit()
+        end;
+
     DeleteCI(HHGear);
 
     if (HHGear^.State and gstMoving) <> 0 then