Fix bug when rope goes through land when hedgehog is sliding
authorunc0rr
Sat, 17 Oct 2009 13:34:40 +0000
changeset 2524 0b075d38fee5
parent 2523 7fc37a16f405
child 2525 e6cdc0251cd1
Fix bug when rope goes through land when hedgehog is sliding
hedgewars/GSHandlers.inc
--- a/hedgewars/GSHandlers.inc	Sat Oct 17 13:19:49 2009 +0000
+++ b/hedgewars/GSHandlers.inc	Sat Oct 17 13:34:40 2009 +0000
@@ -991,8 +991,10 @@
 Gear^.X:= Gear^.X - Gear^.dX;
 Gear^.Y:= Gear^.Y - Gear^.dY;
 Gear^.Elasticity:= Gear^.Elasticity + _1;
+
 HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
 DeleteCI(HHGear);
+
 if (HHGear^.State and gstMoving) <> 0 then
 	begin
 	if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX);
@@ -1011,29 +1013,30 @@
 		HHGear^.Y:= HHGear^.Y + HHGear^.dY;
 		Gear^.Y:= Gear^.Y + HHGear^.dY;
 		HHGear^.dY:= HHGear^.dY + cGravity;
-		tt:= Gear^.Elasticity;
-		tx:= _0;
-		ty:= _0;
-		while tt > _20 do
+		end;
+		
+	tt:= Gear^.Elasticity;
+	tx:= _0;
+	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
 			begin
-			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;
-				Gear^.Elasticity:= tt;
-				Gear^.doStep:= @doStepRopeWork;
-				with HHGear^ do State:= State and not (gstAttacking or gstHHJumping or gstHHHJump);
+			Gear^.X:= Gear^.X + tx;
+			Gear^.Y:= Gear^.Y + ty;
+			Gear^.Elasticity:= tt;
+			Gear^.doStep:= @doStepRopeWork;
+			with HHGear^ do State:= State and not (gstAttacking or gstHHJumping or gstHHHJump);
 
-				RemoveFromAmmo;
+			RemoveFromAmmo;
 
-				tt:= _0;
-				exit
-				end;
-			tx:= tx + Gear^.dX + Gear^.dX;
-			ty:= ty + Gear^.dY + Gear^.dY;
-			tt:= tt - _2;
+			tt:= _0;
+			exit
 			end;
+		tx:= tx + Gear^.dX + Gear^.dX;
+		ty:= ty + Gear^.dY + Gear^.dY;
+		tt:= tt - _2;
 		end;
 	end;