hedgewars/uAmmos.pas
changeset 2409 dbf195c3e09c
parent 2370 2ff8fce5e06f
child 2431 23242609c44b
--- a/hedgewars/uAmmos.pas	Wed Oct 07 17:01:40 2009 +0000
+++ b/hedgewars/uAmmos.pas	Thu Oct 08 00:58:17 2009 +0000
@@ -216,13 +216,16 @@
 
 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)
+		while (CurSlot < cMaxSlotIndex) and (Ammo^[CurSlot, CurAmmo].Count = 0) do 
+                        inc(CurSlot)
 		end;
-
+                
+        //bad things could happen here in case CurSlot is overflowing
 	ApplyAngleBounds(Hedgehog, Ammo^[CurSlot, CurAmmo].AmmoType);
 
 	with Ammo^[CurSlot, CurAmmo] do
@@ -257,7 +260,7 @@
         begin
         CurAmmo:= 0;
         CurSlot:= 0;
-        while (CurSlot <= cMaxSlotIndex) and
+        while (CurSlot < cMaxSlotIndex) and
               ((Ammo^[CurSlot, CurAmmo].Count = 0) or
               (Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0))
               do inc(CurSlot)