hedgewars/uAmmos.pas
changeset 1964 dc9ea05c9d2f
parent 1922 88cdabb51995
child 1966 31e449e1d9dd
--- a/hedgewars/uAmmos.pas	Sun Apr 12 06:01:17 2009 +0000
+++ b/hedgewars/uAmmos.pas	Sun Apr 12 12:50:43 2009 +0000
@@ -27,7 +27,7 @@
 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 ApplyAngleBounds(var Hedgehog: THedgehog; AmmoType: TAmmoType);
 procedure ApplyAmmoChanges(var Hedgehog: THedgehog);
 procedure SwitchNotHeldAmmo(var Hedgehog: THedgehog);
 procedure SetWeapon(weap: TAmmoType);
@@ -180,23 +180,22 @@
 HHHasAmmo:= false
 end;
 
-procedure ApplyAngleBounds(var Hedgehog: THedgehog);
+procedure ApplyAngleBounds(var Hedgehog: THedgehog; AmmoType: TAmmoType);
 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
-		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
+		if Angle < CurMinAngle then Angle:= CurMinAngle;
+		if Angle > CurMaxAngle then Angle:= CurMaxAngle;
 		end
+	end
 end;
 
 procedure ApplyAmmoChanges(var Hedgehog: THedgehog);
@@ -213,7 +212,7 @@
 		while (CurSlot <= cMaxSlotIndex) and (Ammo^[CurSlot, CurAmmo].Count = 0) do inc(CurSlot)
 		end;
 
-	ApplyAngleBounds(Hedgehog);
+	ApplyAngleBounds(Hedgehog, Ammo^[CurSlot, CurAmmo].AmmoType);
 
 	with Ammo^[CurSlot, CurAmmo] do
 		begin