hedgewars/uAmmos.pas
changeset 5676 a655dfab27d7
parent 5640 07676ee23aff
child 5680 c0107c991dda
equal deleted inserted replaced
5675:cd10d6cba644 5676:a655dfab27d7
   154     begin
   154     begin
   155     slot:= Ammoz[am].Slot;
   155     slot:= Ammoz[am].Slot;
   156     ammoidx:= 0;
   156     ammoidx:= 0;
   157     while (ammoidx < cMaxSlotAmmoIndex) and (Ammo^[slot, ammoidx].AmmoType <> am) do inc(ammoidx);
   157     while (ammoidx < cMaxSlotAmmoIndex) and (Ammo^[slot, ammoidx].AmmoType <> am) do inc(ammoidx);
   158     GetAmmoEntry:= @Ammo^[slot, ammoidx];
   158     GetAmmoEntry:= @Ammo^[slot, ammoidx];
   159     end
   159     if (Ammo^[slot, ammoidx].AmmoType <> am) then GetAmmoEntry:= GetAmmoEntry(Hedgehog, amNothing)
       
   160     end;
   160 end;
   161 end;
   161 
   162 
   162 procedure AssignStores;
   163 procedure AssignStores;
   163 var t: LongInt;
   164 var t: LongInt;
   164     i: Longword;
   165     i: Longword;
   178       end
   179       end
   179 end;
   180 end;
   180 
   181 
   181 procedure AddAmmo(var Hedgehog: THedgehog; ammo: TAmmoType);
   182 procedure AddAmmo(var Hedgehog: THedgehog; ammo: TAmmoType);
   182 var cnt: LongWord;
   183 var cnt: LongWord;
   183 begin
   184     a: PAmmo;
   184 cnt:= GetAmmoEntry(Hedgehog, ammo)^.Count;
   185 begin
   185 if cnt <> AMMO_INFINITE then
   186 a:= GetAmmoEntry(Hedgehog, ammo);
       
   187 if (a^.AmmoType = amNothing) or (a^.Count <> AMMO_INFINITE) then
   186     begin
   188     begin
   187     inc(cnt, Ammoz[ammo].NumberInCase);
   189     inc(cnt, Ammoz[ammo].NumberInCase);
   188     AddAmmo(Hedgehog, ammo, cnt)
   190     AddAmmo(Hedgehog, ammo, cnt)
   189     end
   191     end
   190 end;
   192 end;