hedgewars/uAmmos.pas
changeset 2431 23242609c44b
parent 2409 dbf195c3e09c
child 2432 1a0bb82d55f0
equal deleted inserted replaced
2430:b87046cd8ae4 2431:23242609c44b
   219 
   219 
   220 	if (Ammo^[CurSlot, CurAmmo].Count = 0) then
   220 	if (Ammo^[CurSlot, CurAmmo].Count = 0) then
   221 		begin
   221 		begin
   222 		CurAmmo:= 0;
   222 		CurAmmo:= 0;
   223 		CurSlot:= 0;
   223 		CurSlot:= 0;
   224 		while (CurSlot < cMaxSlotIndex) and (Ammo^[CurSlot, CurAmmo].Count = 0) do 
   224 		while (CurSlot <= cMaxSlotIndex) and (Ammo^[CurSlot, CurAmmo].Count = 0) do inc(CurSlot);
   225                         inc(CurSlot)
   225 		TryDo(CurSlot <= cMaxSlotIndex, 'Ammo slot index overflow', true)
   226 		end;
   226 		end;
   227                 
   227 
   228         //bad things could happen here in case CurSlot is overflowing
   228         //bad things could happen here in case CurSlot is overflowing
   229 	ApplyAngleBounds(Hedgehog, Ammo^[CurSlot, CurAmmo].AmmoType);
   229 	ApplyAngleBounds(Hedgehog, Ammo^[CurSlot, CurAmmo].AmmoType);
   230 
   230 
   231 	with Ammo^[CurSlot, CurAmmo] do
   231 	with Ammo^[CurSlot, CurAmmo] do
   232 		begin
   232 		begin
   253 end;
   253 end;
   254 
   254 
   255 procedure SwitchNotHeldAmmo(var Hedgehog: THedgehog);
   255 procedure SwitchNotHeldAmmo(var Hedgehog: THedgehog);
   256 begin
   256 begin
   257 with Hedgehog do
   257 with Hedgehog do
   258      if ((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_DontHold) <> 0) or
   258 	if ((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_DontHold) <> 0) or
   259         (Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0) then
   259 		(Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0) then
   260         begin
   260 		begin
   261         CurAmmo:= 0;
   261 		CurAmmo:= 0;
   262         CurSlot:= 0;
   262 		CurSlot:= 0;
   263         while (CurSlot < cMaxSlotIndex) and
   263 		while (CurSlot <= cMaxSlotIndex) and
   264               ((Ammo^[CurSlot, CurAmmo].Count = 0) or
   264 			((Ammo^[CurSlot, CurAmmo].Count = 0) or
   265               (Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0))
   265 			(Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0))
   266               do inc(CurSlot)
   266 			do
       
   267 			inc(CurSlot);
       
   268 		TryDo(CurSlot <= cMaxSlotIndex, 'Ammo slot index overflow', true)
   267         end
   269         end
   268 end;
   270 end;
   269 
   271 
   270 procedure SetWeapon(weap: TAmmoType);
   272 procedure SetWeapon(weap: TAmmoType);
   271 begin
   273 begin