merge'n'magic
authorsheepluva
Tue, 16 Dec 2014 23:41:26 +0100
changeset 10684 d403fd2f9a6f
parent 10680 4a4a82686e91 (diff)
parent 10683 31a0e7efa17a (current diff)
child 10685 ff3885faf013
merge'n'magic
hedgewars/uGearsHandlersRope.pas
--- a/hedgewars/uGearsHandlersRope.pas	Tue Dec 16 14:32:53 2014 -0500
+++ b/hedgewars/uGearsHandlersRope.pas	Tue Dec 16 23:41:26 2014 +0100
@@ -28,6 +28,9 @@
 uses uConsts, uFloat, uCollisions, uVariables, uGearsList, uSound, uGearsUtils,
     uAmmos, uDebug, uUtils, uGearsHedgehog, uGearsRender;
 
+const
+    IsNilHHFatal = true;
+
 procedure doStepRopeAfterAttack(Gear: PGear);
 var
     HHGear: PGear;
@@ -36,6 +39,7 @@
     HHGear := Gear^.Hedgehog^.Gear;
     if HHGear = nil then
         begin
+        OutError('ERROR: doStepRopeAfterAttack called while HHGear = nil', IsNilHHFatal);
         DeleteGear(Gear);
         exit()
         end;
@@ -127,15 +131,24 @@
     haveDivided: boolean;
     wrongSide: boolean;
 begin
-    if GameTicks mod 4 <> 0 then exit;
-
     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
+        begin
+        PlaySound(sndRopeRelease);
+        RopeDeleteMe(Gear, HHGear);
+        exit
+        end;
+
+    if GameTicks mod 4 <> 0 then exit;
+
     tX:= HHGear^.X;
     if WorldWrap(HHGear) and (WorldEdge = weWrap) and
        ((TestCollisionXwithGear(HHGear, 1) <> 0) or (TestCollisionXwithGear(HHGear, -1) <> 0))  then
@@ -148,14 +161,6 @@
         end;
 
     tX:= HHGear^.X;
-    if ((HHGear^.State and gstHHDriven) = 0) or
-        (CheckGearDrowning(HHGear)) or (Gear^.PortalCounter <> 0) then
-        begin
-        PlaySound(sndRopeRelease);
-        RopeDeleteMe(Gear, HHGear);
-        exit
-        end;
-
     HHGear^.dX.QWordValue:= HHGear^.dX.QWordValue shl 2;
     HHGear^.dY.QWordValue:= HHGear^.dY.QWordValue shl 2;
     if (Gear^.Message and gmLeft  <> 0) and (TestCollisionXwithGear(HHGear, -1) = 0) then
@@ -427,6 +432,7 @@
     HHGear := Gear^.Hedgehog^.Gear;
     if HHGear = nil then
         begin
+        OutError('ERROR: doStepRopeAttach called while HHGear = nil', IsNilHHFatal);
         DeleteGear(Gear);
         exit()
         end;