hedgewars/GSHandlers.inc
changeset 5042 f26c5eb040af
parent 5041 3dc6ad20cbfe
child 5044 6e8da75e5f5e
equal deleted inserted replaced
5041:3dc6ad20cbfe 5042:f26c5eb040af
  3677 
  3677 
  3678 procedure doStepPortal(Gear: PGear);
  3678 procedure doStepPortal(Gear: PGear);
  3679 var 
  3679 var 
  3680     iterator, conPortal: PGear;
  3680     iterator, conPortal: PGear;
  3681     s, r, nx, ny, ox, oy, poffs, noffs, pspeed, nspeed: hwFloat;
  3681     s, r, nx, ny, ox, oy, poffs, noffs, pspeed, nspeed: hwFloat;
       
  3682     o_x,o_y,r_x,r_y,rr_x,rr_y: LongInt;
  3682     hasdxy, isbullet, iscake: Boolean;
  3683     hasdxy, isbullet, iscake: Boolean;
  3683 begin
  3684 begin
  3684     doPortalColorSwitch();
  3685     doPortalColorSwitch();
  3685 
  3686 
  3686     // destroy portal if ground it was attached too is gone
  3687     // destroy portal if ground it was attached too is gone
  3747         if (iterator^.X < Gear^.X - r)
  3748         if (iterator^.X < Gear^.X - r)
  3748            or (iterator^.X > Gear^.X + r)
  3749            or (iterator^.X > Gear^.X + r)
  3749            or (iterator^.Y < Gear^.Y - r)
  3750            or (iterator^.Y < Gear^.Y - r)
  3750            or (iterator^.Y > Gear^.Y + r) then
  3751            or (iterator^.Y > Gear^.Y + r) then
  3751             continue;
  3752             continue;
       
  3753 
       
  3754         //Will if fit through?
       
  3755 
       
  3756         o_x := hwRound(conPortal^.X + conPortal^.dX);
       
  3757         o_y := hwRound(conPortal^.Y + conPortal^.dY);
       
  3758         r_x := hwRound(conPortal^.X+r*conPortal^.dX);
       
  3759         r_y := hwRound(conPortal^.Y+r*conPortal^.dY);
       
  3760         rr_x := hwRound(conPortal^.X+r*conPortal^.dX*2);
       
  3761         rr_y := hwRound(conPortal^.Y+r*conPortal^.dY*2);
       
  3762 
       
  3763         //check outer edge
       
  3764         if (((rr_y and LAND_HEIGHT_MASK) <> 0) or ((rr_x and LAND_WIDTH_MASK) <> 0)) then
       
  3765             begin
       
  3766             if hasBorder then continue;
       
  3767             end
       
  3768         else
       
  3769             if ((Land[rr_y,rr_x] and $FF00) <> 0) then
       
  3770                 continue;
       
  3771         //check middle bound
       
  3772         if (((r_y and LAND_HEIGHT_MASK) <> 0) or ((r_x and LAND_WIDTH_MASK) <> 0)) then
       
  3773             begin
       
  3774             if hasBorder then continue;
       
  3775             end
       
  3776         else
       
  3777         if ((Land[r_y, r_x] and $FF00) <> 0) then
       
  3778                 continue;
       
  3779         //check inner bound
       
  3780         if (((o_y and LAND_HEIGHT_MASK) <> 0) or ((o_x and LAND_WIDTH_MASK) <> 0)) then
       
  3781             begin
       
  3782             if hasBorder then continue;
       
  3783             end
       
  3784         else
       
  3785         if ((Land[o_y, o_x] and $FF00) <> 0) then
       
  3786                 continue;
       
  3787         //check left bound
       
  3788         if (((rr_y and LAND_HEIGHT_MASK) <> 0) or ((o_x and LAND_WIDTH_MASK) <> 0)) then
       
  3789             begin
       
  3790             if hasBorder then continue;
       
  3791             end
       
  3792         else
       
  3793         if ((Land[rr_y, o_x] and $FF00) <> 0) then
       
  3794                 continue;
       
  3795         //Check Right Bound
       
  3796         if (((o_y and LAND_HEIGHT_MASK) <> 0) or ((rr_x and LAND_WIDTH_MASK) <> 0)) then
       
  3797             begin
       
  3798             if hasBorder then continue;
       
  3799             end
       
  3800         else
       
  3801         if ((Land[o_y, rr_x] and $FF00) <> 0) then
       
  3802                 continue;
  3752 
  3803 
  3753         hasdxy := (((iterator^.dX.QWordValue <> 0) or (iterator^.dY.QWordValue <> 0))
  3804         hasdxy := (((iterator^.dX.QWordValue <> 0) or (iterator^.dY.QWordValue <> 0))
  3754                     or ((iterator^.State or gstMoving) = 0));
  3805                     or ((iterator^.State or gstMoving) = 0));
  3755 
  3806 
  3756         // in case the object is not moving, let's asume it's falling towards the portal
  3807         // in case the object is not moving, let's asume it's falling towards the portal