--- a/hedgewars/uAmmos.pas Tue Jul 10 11:08:35 2012 +0200
+++ b/hedgewars/uAmmos.pas Tue Jul 10 11:09:38 2012 +0200
@@ -32,6 +32,7 @@
procedure SetAmmoReinforcement(var s: shortstring);
procedure AssignStores;
procedure AddAmmo(var Hedgehog: THedgehog; ammo: TAmmoType);
+procedure AddAmmo(var Hedgehog: THedgehog; ammo: TAmmoType; amt: LongWord);
procedure SetAmmo(var Hedgehog: THedgehog; ammo: TAmmoType; cnt: LongWord);
function HHHasAmmo(var Hedgehog: THedgehog; Ammo: TAmmoType): LongWord;
procedure PackAmmo(Ammo: PHHAmmo; Slot: LongInt);
@@ -188,7 +189,7 @@
end
end;
-procedure AddAmmo(var Hedgehog: THedgehog; ammo: TAmmoType);
+procedure AddAmmo(var Hedgehog: THedgehog; ammo: TAmmoType; amt: LongWord);
var cnt: LongWord;
a: PAmmo;
begin
@@ -199,11 +200,16 @@
cnt:= 0;
if (cnt <> AMMO_INFINITE) then
begin
- inc(cnt, Ammoz[ammo].NumberInCase);
+ inc(cnt, amt);
SetAmmo(Hedgehog, ammo, cnt)
end
end;
+procedure AddAmmo(var Hedgehog: THedgehog; ammo: TAmmoType);
+begin
+ AddAmmo(Hedgehog, ammo, Ammoz[ammo].NumberInCase);
+end;
+
procedure SetAmmo(var Hedgehog: THedgehog; ammo: TAmmoType; cnt: LongWord);
var ammos: TAmmoCounts;
slot, ami: LongInt;
@@ -297,22 +303,23 @@
procedure ApplyAngleBounds(var Hedgehog: THedgehog; AmmoType: TAmmoType);
begin
-with Hedgehog do
- begin
- CurMinAngle:= Ammoz[AmmoType].minAngle;
- if Ammoz[AmmoType].maxAngle <> 0 then
- CurMaxAngle:= Ammoz[AmmoType].maxAngle
- else
- CurMaxAngle:= cMaxAngle;
+if Hedgehog.Gear <> nil then
+ with Hedgehog 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;
+ with Hedgehog.Gear^ do
+ begin
+ if Angle < CurMinAngle then
+ Angle:= CurMinAngle;
+ if Angle > CurMaxAngle then
+ Angle:= CurMaxAngle;
+ end
end
- end
end;
procedure SwitchToFirstLegalAmmo(var Hedgehog: THedgehog);
@@ -374,12 +381,12 @@
AddCaption(s, Team^.Clan^.Color, capgrpAmmoinfo);
if (Propz and ammoprop_NeedTarget) <> 0 then
begin
- Gear^.State:= Gear^.State or gstHHChooseTarget;
+ if Gear <> nil then Gear^.State:= Gear^.State or gstHHChooseTarget;
isCursorVisible:= true
end
else
begin
- Gear^.State:= Gear^.State and not gstHHChooseTarget;
+ if Gear <> nil then Gear^.State:= Gear^.State and not gstHHChooseTarget;
isCursorVisible:= false
end;
end