diff -r 7b44d8fb87e5 -r 9835060e5c01 hedgewars/HHHandlers.inc --- a/hedgewars/HHHandlers.inc Sun Oct 10 17:13:20 2010 +0200 +++ b/hedgewars/HHHandlers.inc Sun Oct 10 12:08:16 2010 -0400 @@ -42,7 +42,8 @@ // Shouldn't more of this ammo switching stuff be moved to uAmmos ? procedure ChangeAmmo(Gear: PGear); -var slot, ammoidx, i: Longword; +var slot, i: Longword; + ammoidx: LongInt; begin slot:= Gear^.MsgParam; @@ -73,7 +74,8 @@ TryDo(i < 2, 'Engine bug: no ammo in current slot', true) end; until (Ammo^[slot, ammoidx].Count > 0) and (Team^.Clan^.TurnNumber > Ammoz[Ammo^[slot, ammoidx].AmmoType].SkipTurns) - end else + end + else begin i:= 0; // check whether there is ammo in slot @@ -82,8 +84,9 @@ or (Team^.Clan^.TurnNumber <= Ammoz[Ammo^[slot, i].AmmoType].SkipTurns)) do inc(i); if i <= cMaxSlotAmmoIndex then ammoidx:= i + else ammoidx:= -1 end; - CurAmmoType:= Ammo^[slot, ammoidx].AmmoType; + if ammoidx >= 0 then CurAmmoType:= Ammo^[slot, ammoidx].AmmoType; end end;