hedgewars/uGearsHandlersRope.pas
changeset 10684 d403fd2f9a6f
parent 10680 4a4a82686e91
parent 10681 474d418a34c5
child 10722 37264e44ec0f
equal deleted inserted replaced
10680:4a4a82686e91 10684:d403fd2f9a6f
    26 
    26 
    27 implementation
    27 implementation
    28 uses uConsts, uFloat, uCollisions, uVariables, uGearsList, uSound, uGearsUtils,
    28 uses uConsts, uFloat, uCollisions, uVariables, uGearsList, uSound, uGearsUtils,
    29     uAmmos, uDebug, uUtils, uGearsHedgehog, uGearsRender;
    29     uAmmos, uDebug, uUtils, uGearsHedgehog, uGearsRender;
    30 
    30 
       
    31 const
       
    32     IsNilHHFatal = true;
       
    33 
    31 procedure doStepRopeAfterAttack(Gear: PGear);
    34 procedure doStepRopeAfterAttack(Gear: PGear);
    32 var
    35 var
    33     HHGear: PGear;
    36     HHGear: PGear;
    34     tX:     hwFloat;
    37     tX:     hwFloat;
    35 begin
    38 begin
    36     HHGear := Gear^.Hedgehog^.Gear;
    39     HHGear := Gear^.Hedgehog^.Gear;
       
    40     if HHGear = nil then
       
    41         begin
       
    42         OutError('ERROR: doStepRopeAfterAttack called while HHGear = nil', IsNilHHFatal);
       
    43         DeleteGear(Gear);
       
    44         exit()
       
    45         end;
       
    46 
    37     tX:= HHGear^.X;
    47     tX:= HHGear^.X;
    38     if WorldWrap(HHGear) and (WorldEdge = weWrap) and
    48     if WorldWrap(HHGear) and (WorldEdge = weWrap) and
    39        ((TestCollisionXwithGear(HHGear, 1) <> 0) or (TestCollisionXwithGear(HHGear, -1) <> 0))  then
    49        ((TestCollisionXwithGear(HHGear, 1) <> 0) or (TestCollisionXwithGear(HHGear, -1) <> 0))  then
    40         begin
    50         begin
    41         HHGear^.X:= tX;
    51         HHGear^.X:= tX;
   120     haveCollision,
   130     haveCollision,
   121     haveDivided: boolean;
   131     haveDivided: boolean;
   122     wrongSide: boolean;
   132     wrongSide: boolean;
   123 begin
   133 begin
   124     HHGear := Gear^.Hedgehog^.Gear;
   134     HHGear := Gear^.Hedgehog^.Gear;
       
   135     if HHGear = nil then
       
   136         begin
       
   137         OutError('ERROR: doStepRopeWork called while HHGear = nil', IsNilHHFatal);
       
   138         DeleteGear(Gear);
       
   139         exit()
       
   140         end;
   125 
   141 
   126     if ((HHGear^.State and gstHHDriven) = 0) or
   142     if ((HHGear^.State and gstHHDriven) = 0) or
   127         (CheckGearDrowning(HHGear)) or (Gear^.PortalCounter <> 0) then
   143         (CheckGearDrowning(HHGear)) or (Gear^.PortalCounter <> 0) then
   128         begin
   144         begin
   129         PlaySound(sndRopeRelease);
   145         PlaySound(sndRopeRelease);
   412     Gear^.X := Gear^.X - Gear^.dX;
   428     Gear^.X := Gear^.X - Gear^.dX;
   413     Gear^.Y := Gear^.Y - Gear^.dY;
   429     Gear^.Y := Gear^.Y - Gear^.dY;
   414     Gear^.Elasticity := Gear^.Elasticity + _1;
   430     Gear^.Elasticity := Gear^.Elasticity + _1;
   415 
   431 
   416     HHGear := Gear^.Hedgehog^.Gear;
   432     HHGear := Gear^.Hedgehog^.Gear;
       
   433     if HHGear = nil then
       
   434         begin
       
   435         OutError('ERROR: doStepRopeAttach called while HHGear = nil', IsNilHHFatal);
       
   436         DeleteGear(Gear);
       
   437         exit()
       
   438         end;
       
   439 
   417     DeleteCI(HHGear);
   440     DeleteCI(HHGear);
   418 
   441 
   419     if (HHGear^.State and gstMoving) <> 0 then
   442     if (HHGear^.State and gstMoving) <> 0 then
   420         begin
   443         begin
   421         if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) <> 0 then
   444         if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) <> 0 then