Fix bug with rope and bazooka
authorunc0rr
Thu, 26 Mar 2009 19:22:40 +0000
changeset 1922 88cdabb51995
parent 1921 2a09f7f786a0
child 1923 956b6b3529bc
Fix bug with rope and bazooka
hedgewars/GSHandlers.inc
hedgewars/HHHandlers.inc
hedgewars/uAmmos.pas
hedgewars/uTeams.pas
--- a/hedgewars/GSHandlers.inc	Thu Mar 26 16:54:16 2009 +0000
+++ b/hedgewars/GSHandlers.inc	Thu Mar 26 19:22:40 2009 +0000
@@ -771,7 +771,7 @@
 ////
 
 
-haveDivided:= false;
+	haveDivided:= false;
 	// check whether rope needs dividing
 	len:= _1 / Distance(ropeDx, ropeDy); // old rope pos
 	nx:= ropeDx * len;
@@ -849,7 +849,11 @@
 
 if (Gear^.Message and gm_Attack) <> 0 then
 	if (Gear^.State and gsttmpFlag) <> 0 then
-		WaitCollision
+		with PHedgehog(Gear^.Hedgehog)^ do
+			if Ammo^[CurSlot, CurAmmo].AmmoType = amRope then
+				WaitCollision
+			else
+				DeleteMe
 	else
 else
 	if (Gear^.State and gsttmpFlag) = 0 then
--- a/hedgewars/HHHandlers.inc	Thu Mar 26 16:54:16 2009 +0000
+++ b/hedgewars/HHHandlers.inc	Thu Mar 26 19:22:40 2009 +0000
@@ -127,6 +127,7 @@
            StopSound(sndThrowPowerUp);
            PlaySound(sndThrowRelease, false, nil);
            end;
+
         xx:= SignAs(AngleSin(Angle), dX);
         yy:= -AngleCos(Angle);
 
--- a/hedgewars/uAmmos.pas	Thu Mar 26 16:54:16 2009 +0000
+++ b/hedgewars/uAmmos.pas	Thu Mar 26 19:22:40 2009 +0000
@@ -27,8 +27,9 @@
 function  HHHasAmmo(var Hedgehog: THedgehog; Ammo: TAmmoType): boolean;
 procedure PackAmmo(Ammo: PHHAmmo; Slot: LongInt);
 procedure OnUsedAmmo(var Hedgehog: THedgehog);
+procedure ApplyAngleBounds(var Hedgehog: THedgehog);
 procedure ApplyAmmoChanges(var Hedgehog: THedgehog);
-procedure SwitchNotHoldedAmmo(var Hedgehog: THedgehog);
+procedure SwitchNotHeldAmmo(var Hedgehog: THedgehog);
 procedure SetWeapon(weap: TAmmoType);
 procedure DisableSomeWeapons;
 
@@ -158,7 +159,7 @@
 			if Count = 0 then
 				begin
 				PackAmmo(Ammo, CurSlot);
-				SwitchNotHoldedAmmo(Hedgehog)
+				SwitchNotHeldAmmo(Hedgehog)
 				end
 			end
 	end
@@ -179,51 +180,63 @@
 HHHasAmmo:= false
 end;
 
+procedure ApplyAngleBounds(var Hedgehog: THedgehog);
+begin
+with Hedgehog do
+	with Ammo^[CurSlot, CurAmmo] do
+		begin
+		CurMinAngle:= Ammoz[AmmoType].minAngle;
+		if Ammoz[AmmoType].maxAngle <> 0 then
+			CurMaxAngle:= Ammoz[AmmoType].maxAngle
+		else
+			CurMaxAngle:= cMaxAngle;
+
+		with Hedgehog.Gear^ do
+			begin
+			if Angle < CurMinAngle then Angle:= CurMinAngle;
+			if Angle > CurMaxAngle then Angle:= CurMaxAngle;
+			end
+		end
+end;
+
 procedure ApplyAmmoChanges(var Hedgehog: THedgehog);
 var s: shortstring;
 begin
 TargetPoint.X:= NoPointX;
 
 with Hedgehog do
-     begin
-     if (Ammo^[CurSlot, CurAmmo].Count = 0) then
-        begin
-        CurAmmo:= 0;
-        CurSlot:= 0;
-        while (CurSlot <= cMaxSlotIndex) and (Ammo^[CurSlot, CurAmmo].Count = 0) do inc(CurSlot)
-        end;
+	begin
+	if (Ammo^[CurSlot, CurAmmo].Count = 0) then
+		begin
+		CurAmmo:= 0;
+		CurSlot:= 0;
+		while (CurSlot <= cMaxSlotIndex) and (Ammo^[CurSlot, CurAmmo].Count = 0) do inc(CurSlot)
+		end;
+
+	ApplyAngleBounds(Hedgehog);
 
-with Ammo^[CurSlot, CurAmmo] do
-     begin
-     CurMinAngle:= Ammoz[AmmoType].minAngle;
-     if Ammoz[AmmoType].maxAngle <> 0 then CurMaxAngle:= Ammoz[AmmoType].maxAngle
-                                      else CurMaxAngle:= cMaxAngle;
-     with Hedgehog.Gear^ do
-        begin
-        if Angle < CurMinAngle then Angle:= CurMinAngle;
-        if Angle > CurMaxAngle then Angle:= CurMaxAngle;
-        end;
-
-     s:= trammo[Ammoz[AmmoType].NameId];
-     if Count <> AMMO_INFINITE then
-        s:= s + ' (' + IntToStr(Count) + ')';
-     if (Propz and ammoprop_Timerable) <> 0 then
-        s:= s + ', ' + inttostr(Timer div 1000) + ' ' + trammo[sidSeconds];
-     AddCaption(s, Team^.Clan^.Color, capgrpAmmoinfo);
-     if (Propz and ammoprop_NeedTarget) <> 0
-        then begin
-        Gear^.State:= Gear^.State or      gstHHChooseTarget;
-        isCursorVisible:= true
-        end else begin
-        Gear^.State:= Gear^.State and not gstHHChooseTarget;
-        isCursorVisible:= false
-        end;
-     ShowCrosshair:= (Propz and ammoprop_NoCrosshair) = 0
-     end
-     end
+	with Ammo^[CurSlot, CurAmmo] do
+		begin
+		s:= trammo[Ammoz[AmmoType].NameId];
+		if Count <> AMMO_INFINITE then
+			s:= s + ' (' + IntToStr(Count) + ')';
+		if (Propz and ammoprop_Timerable) <> 0 then
+			s:= s + ', ' + inttostr(Timer div 1000) + ' ' + trammo[sidSeconds];
+		AddCaption(s, Team^.Clan^.Color, capgrpAmmoinfo);
+		if (Propz and ammoprop_NeedTarget) <> 0
+			then begin
+			Gear^.State:= Gear^.State or      gstHHChooseTarget;
+			isCursorVisible:= true
+			end else begin
+			Gear^.State:= Gear^.State and not gstHHChooseTarget;
+			isCursorVisible:= false
+			end;
+		ShowCrosshair:= (Propz and ammoprop_NoCrosshair) = 0
+		end
+	end
 end;
 
-procedure SwitchNotHoldedAmmo(var Hedgehog: THedgehog);
+procedure SwitchNotHeldAmmo(var Hedgehog: THedgehog);
 begin
 with Hedgehog do
      if ((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_DontHold) <> 0) or
--- a/hedgewars/uTeams.pas	Thu Mar 26 16:54:16 2009 +0000
+++ b/hedgewars/uTeams.pas	Thu Mar 26 19:22:40 2009 +0000
@@ -206,7 +206,7 @@
 procedure AfterSwitchHedgehog;
 var g: PGear;
 begin
-SwitchNotHoldedAmmo(CurrentHedgehog^);
+SwitchNotHeldAmmo(CurrentHedgehog^);
 with CurrentHedgehog^ do
 	begin
 	with Gear^ do