hedgewars/uAmmos.pas
changeset 6990 40e5af28d026
parent 6924 57b66ee3bff3
child 7037 7edce323558f
equal deleted inserted replaced
6989:4c35e9cf6057 6990:40e5af28d026
   143 FillAmmoStore(StoresList[Pred(StoreCnt)], ammos)
   143 FillAmmoStore(StoresList[Pred(StoreCnt)], ammos)
   144 end;
   144 end;
   145 
   145 
   146 function GetAmmoByNum(num: Longword): PHHAmmo;
   146 function GetAmmoByNum(num: Longword): PHHAmmo;
   147 begin
   147 begin
   148 TryDo(num < StoreCnt, 'Invalid store number', true);
   148     TryDo(num < StoreCnt, 'Invalid store number', true);
   149 exit(StoresList[num])
   149     GetAmmoByNum:= StoresList[num]
   150 end;
   150 end;
   151 
   151 
   152 function GetCurAmmoEntry(var Hedgehog: THedgehog): PAmmo;
   152 function GetCurAmmoEntry(var Hedgehog: THedgehog): PAmmo;
   153 begin
   153 begin
   154 GetCurAmmoEntry:= GetAmmoEntry(Hedgehog, Hedgehog.CurAmmoType)
   154     GetCurAmmoEntry:= GetAmmoEntry(Hedgehog, Hedgehog.CurAmmoType)
   155 end;
   155 end;
   156 
   156 
   157 function GetAmmoEntry(var Hedgehog: THedgehog; am: TAmmoType): PAmmo;
   157 function GetAmmoEntry(var Hedgehog: THedgehog; am: TAmmoType): PAmmo;
   158 var ammoidx, slot: LongWord;
   158 var ammoidx, slot: LongWord;
   159 begin
   159 begin
   278 end;
   278 end;
   279 
   279 
   280 function  HHHasAmmo(var Hedgehog: THedgehog; Ammo: TAmmoType): LongWord;
   280 function  HHHasAmmo(var Hedgehog: THedgehog; Ammo: TAmmoType): LongWord;
   281 var slot, ami: LongInt;
   281 var slot, ami: LongInt;
   282 begin
   282 begin
   283 Slot:= Ammoz[Ammo].Slot;
   283     HHHasAmmo:= 0;
   284 ami:= 0;
   284     Slot:= Ammoz[Ammo].Slot;
   285 while (ami <= cMaxSlotAmmoIndex) do
   285     ami:= 0;
   286         begin
   286     while (ami <= cMaxSlotAmmoIndex) do
       
   287     begin
   287         with Hedgehog.Ammo^[Slot, ami] do
   288         with Hedgehog.Ammo^[Slot, ami] do
   288             if (AmmoType = Ammo) then
   289             if (AmmoType = Ammo) then
   289                 if Hedgehog.Team^.Clan^.TurnNumber > Ammoz[AmmoType].SkipTurns then
   290                 if Hedgehog.Team^.Clan^.TurnNumber > Ammoz[AmmoType].SkipTurns then
   290                     exit(Count)
   291                 begin
   291                 else exit(0);
   292                     HHHasAmmo:= Count;
   292       inc(ami)
   293                     exit;
   293       end;
   294                 end
   294 HHHasAmmo:= 0
   295                 else exit;
       
   296         inc(ami)
       
   297     end;
   295 end;
   298 end;
   296 
   299 
   297 procedure ApplyAngleBounds(var Hedgehog: THedgehog; AmmoType: TAmmoType);
   300 procedure ApplyAngleBounds(var Hedgehog: THedgehog; AmmoType: TAmmoType);
   298 begin
   301 begin
   299 with Hedgehog do
   302 with Hedgehog do