--- a/hedgewars/uAmmos.pas Mon Oct 12 16:50:42 2009 +0000
+++ b/hedgewars/uAmmos.pas Mon Oct 12 16:53:01 2009 +0000
@@ -221,10 +221,10 @@
begin
CurAmmo:= 0;
CurSlot:= 0;
- while (CurSlot < cMaxSlotIndex) and (Ammo^[CurSlot, CurAmmo].Count = 0) do
- inc(CurSlot)
+ while (CurSlot <= cMaxSlotIndex) and (Ammo^[CurSlot, CurAmmo].Count = 0) do inc(CurSlot);
+ TryDo(CurSlot <= cMaxSlotIndex, 'Ammo slot index overflow', true)
end;
-
+
//bad things could happen here in case CurSlot is overflowing
ApplyAngleBounds(Hedgehog, Ammo^[CurSlot, CurAmmo].AmmoType);
@@ -255,15 +255,17 @@
procedure SwitchNotHeldAmmo(var Hedgehog: THedgehog);
begin
with Hedgehog do
- if ((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_DontHold) <> 0) or
- (Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0) then
- begin
- CurAmmo:= 0;
- CurSlot:= 0;
- while (CurSlot < cMaxSlotIndex) and
- ((Ammo^[CurSlot, CurAmmo].Count = 0) or
- (Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0))
- do inc(CurSlot)
+ if ((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_DontHold) <> 0) or
+ (Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0) then
+ begin
+ CurAmmo:= 0;
+ CurSlot:= 0;
+ while (CurSlot <= cMaxSlotIndex) and
+ ((Ammo^[CurSlot, CurAmmo].Count = 0) or
+ (Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0))
+ do
+ inc(CurSlot);
+ TryDo(CurSlot <= cMaxSlotIndex, 'Ammo slot index overflow', true)
end
end;
--- a/hedgewars/uTeams.pas Mon Oct 12 16:50:42 2009 +0000
+++ b/hedgewars/uTeams.pas Mon Oct 12 16:53:01 2009 +0000
@@ -208,7 +208,10 @@
procedure AfterSwitchHedgehog;
var g: PGear;
begin
+inc(CurrentTeam^.Clan^.TurnNumber);
+
SwitchNotHeldAmmo(CurrentHedgehog^);
+
with CurrentHedgehog^ do
begin
with Gear^ do
@@ -222,8 +225,6 @@
FollowGear:= Gear
end;
-inc(CurrentTeam^.Clan^.TurnNumber);
-
ResetKbd;
cWindSpeed:= rndSign(GetRandom * cMaxWindSpeed);