- Don't kick cases by moving hedgehog
authorunc0rr
Mon, 21 May 2007 18:07:25 +0000
changeset 517 ba560c17c24c
parent 516 f682e134ac2e
child 518 d48d8c0a546d
- Don't kick cases by moving hedgehog - Fix hedgehog not registering in collisions array when changing direction without making a step - Fix old rope regression (attaching didn't work properly, when hedgehog is jumping)
hedgewars/GSHandlers.inc
hedgewars/HHHandlers.inc
hedgewars/uCollisions.pas
--- a/hedgewars/GSHandlers.inc	Mon May 21 15:42:21 2007 +0000
+++ b/hedgewars/GSHandlers.inc	Mon May 21 18:07:25 2007 +0000
@@ -643,6 +643,7 @@
 Gear^.Y:= Gear^.Y - Gear^.dY;
 Gear^.Elasticity:= Gear^.Elasticity + _1;
 HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
+DeleteCI(HHGear);
 if (HHGear^.State and gstFalling) <> 0 then
    if TestCollisionYwithGear(HHGear, 1) then
       begin
@@ -662,8 +663,8 @@
       ty:= _0;
       while tt > _20 do
             begin
-            if  TestCollisionXwithXYShift(Gear, tx, hwRound(ty), hwSign(Gear^.dX))
-             or TestCollisionYwithXYShift(Gear, hwRound(tx), hwRound(ty), hwSign(Gear^.dY)) then
+            if  TestCollisionXwithXYShift(Gear, tx, hwRound(ty), -hwSign(Gear^.dX))
+             or TestCollisionYwithXYShift(Gear, hwRound(tx), hwRound(ty), -hwSign(Gear^.dY)) then
                 begin
                 Gear^.X:= Gear^.X + tx;
                 Gear^.Y:= Gear^.Y + ty;
@@ -672,8 +673,8 @@
                 with HHGear^ do State:= State and not gstAttacking;
                 tt:= _0
                 end;
-            tx:= tx + Gear^.dX - Gear^.dX;
-            ty:= ty + Gear^.dY - Gear^.dY;
+            tx:= tx + Gear^.dX + Gear^.dX;
+            ty:= ty + Gear^.dY + Gear^.dY;
             tt:= tt - _2;
             end;
       end;
@@ -987,6 +988,7 @@
 begin
 HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
 HHGear^.State:= HHGear^.State and not gstAttacking;
+DeleteCI(HHGear);
 
 inc(Gear^.Timer);
 
--- a/hedgewars/HHHandlers.inc	Mon May 21 15:42:21 2007 +0000
+++ b/hedgewars/HHHandlers.inc	Mon May 21 18:07:25 2007 +0000
@@ -183,10 +183,11 @@
    PrevdX:= hwSign(Gear^.dX);
    if (Gear^.Message and gm_Left  )<>0 then Gear^.dX:= -cLittle else
    if (Gear^.Message and gm_Right )<>0 then Gear^.dX:=  cLittle else exit;
-   DeleteCI(Gear);
 
    StepTicks:= cHHStepTicks;
    if PrevdX <> hwSign(Gear^.dX) then exit;
+   DeleteCI(Gear); // after exit!!    ^^^^
+   
    PHedgehog(Gear^.Hedgehog)^.visStepPos:= (PHedgehog(Gear^.Hedgehog)^.visStepPos + 1) and 7;
    if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then
       begin
--- a/hedgewars/uCollisions.pas	Mon May 21 15:42:21 2007 +0000
+++ b/hedgewars/uCollisions.pas	Mon May 21 18:07:25 2007 +0000
@@ -191,7 +191,7 @@
    end;
 TestCollisionXKick:= false;
 
-if flag then
+if flag and (Gear^.dX > cHHKick) then
    begin
    if Count = 0 then exit;
    mx:= hwRound(Gear^.X);
@@ -201,7 +201,8 @@
     with cinfos[i] do
       if (Gear <> cGear) and
          (sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius)) and
-         ((mx > x) xor (Dir > 0)) then  // FIXME: Check Gear.Kind
+         ((mx > x) xor (Dir > 0)) then
+         if (cinfos[i].cGear^.Kind in [gtHedgehog, gtMine]) then
              begin
              Gear^.dX:= Gear^.dX {* _0_6};
              Gear^.dY:= Gear^.dY {* _0_6};
@@ -214,7 +215,7 @@
                   end;
              DeleteCI(cinfos[i].cGear);
              exit
-             end
+             end else exit(true)
    end
 end;
 
@@ -240,7 +241,7 @@
    end;
 TestCollisionYKick:= false;
 
-if flag then
+if flag and (Gear^.dX > cHHKick) then
    begin
    if Count = 0 then exit;
    mx:= hwRound(Gear^.X);
@@ -251,9 +252,10 @@
       if (Gear <> cGear) and
          (sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius)) and
          ((my > y) xor (Dir > 0)) then
+         if (cinfos[i].cGear^.Kind in [gtHedgehog, gtMine]) then
              begin
-             Gear^.dX:= Gear^.dX * _0_6;
-             Gear^.dY:= Gear^.dY * _0_6;
+             Gear^.dX:= Gear^.dX {* _0_6};
+             Gear^.dY:= Gear^.dY {* _0_6};
              with cinfos[i].cGear^ do
                   begin
                   dX:= Gear^.dX {* _1_5};
@@ -263,7 +265,7 @@
                   end;
              DeleteCI(cinfos[i].cGear);
              exit
-             end
+             end else exit(true)
    end
 end;