diff -r 2a09f7f786a0 -r 88cdabb51995 hedgewars/uAmmos.pas --- 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