hedgewars/uAmmos.pas
changeset 13455 38814954a248
parent 13454 794dcf69a5aa
child 13499 c41b16ac2e05
equal deleted inserted replaced
13454:794dcf69a5aa 13455:38814954a248
    50 var StoreCnt: LongInt;
    50 var StoreCnt: LongInt;
    51 
    51 
    52 implementation
    52 implementation
    53 uses uVariables, uCommands, uUtils, uCaptions, uDebug, uScript;
    53 uses uVariables, uCommands, uUtils, uCaptions, uDebug, uScript;
    54 
    54 
    55 type TAmmoCounts = array[TAmmoType] of Longword;
    55 type TAmmoArray = array[TAmmoType] of TAmmo;
    56      TAmmoArray = array[TAmmoType] of TAmmo;
       
    57 var StoresList: array[0..Pred(cMaxHHs)] of PHHAmmo;
    56 var StoresList: array[0..Pred(cMaxHHs)] of PHHAmmo;
    58     ammoLoadout, ammoProbability, ammoDelay, ammoReinforcement: shortstring;
    57     ammoLoadout, ammoProbability, ammoDelay, ammoReinforcement: shortstring;
    59     InitialCounts: array[0..Pred(cMaxHHs)] of TAmmoCounts;
    58     InitialCountsLocal: array[0..Pred(cMaxHHs)] of TAmmoCounts;
    60 
    59 
    61 procedure FillAmmoStore(Ammo: PHHAmmo; var newAmmo: TAmmoArray);
    60 procedure FillAmmoStore(Ammo: PHHAmmo; var newAmmo: TAmmoArray);
    62 var mi: array[0..cMaxSlotIndex] of byte;
    61 var mi: array[0..cMaxSlotIndex] of byte;
    63     a: TAmmoType;
    62     a: TAmmoType;
    64 begin
    63 begin
   137         end
   136         end
   138 
   137 
   139     else
   138     else
   140         ammos[a]:= AMMO_INFINITE;
   139         ammos[a]:= AMMO_INFINITE;
   141     if ((GameFlags and gfPlaceHog) <> 0) and (a = amTeleport) then
   140     if ((GameFlags and gfPlaceHog) <> 0) and (a = amTeleport) then
   142         InitialCounts[Pred(StoreCnt)][a]:= cnt
   141         begin
       
   142         InitialCountsLocal[Pred(StoreCnt)][a]:= cnt;
       
   143         InitialAmmoCounts[a]:= cnt;
       
   144         end
   143     else
   145     else
   144         InitialCounts[Pred(StoreCnt)][a]:= ammos[a];
   146         begin
       
   147         InitialCountsLocal[Pred(StoreCnt)][a]:= ammos[a];
       
   148         InitialAmmoCounts[a]:= ammos[a];
       
   149         end
   145     end;
   150     end;
   146 
   151 
   147     for a:= Low(TAmmoType) to High(TAmmoType) do
   152     for a:= Low(TAmmoType) to High(TAmmoType) do
   148         begin
   153         begin
   149         newAmmos[a]:= Ammoz[a].Ammo;
   154         newAmmos[a]:= Ammoz[a].Ammo;
   455         for a:= 0 to cMaxSlotAmmoIndex do
   460         for a:= 0 to cMaxSlotAmmoIndex do
   456             with StoresList[i]^[slot, a] do
   461             with StoresList[i]^[slot, a] do
   457                 if (Propz and ammoprop_NotBorder) <> 0 then
   462                 if (Propz and ammoprop_NotBorder) <> 0 then
   458                     begin
   463                     begin
   459                     Count:= 0;
   464                     Count:= 0;
   460                     InitialCounts[i][AmmoType]:= 0
   465                     InitialCountsLocal[i][AmmoType]:= 0
   461                     end;
   466                     end;
   462 
   467 
   463         PackAmmo(StoresList[i], slot)
   468         PackAmmo(StoresList[i], slot)
   464         end;
   469         end;
   465 
   470 
   503     newAmmos[a]:= Ammoz[a].Ammo;
   508     newAmmos[a]:= Ammoz[a].Ammo;
   504 
   509 
   505 for i:= 0 to Pred(StoreCnt) do
   510 for i:= 0 to Pred(StoreCnt) do
   506     begin
   511     begin
   507     for a:= Low(TAmmoType) to High(TAmmoType) do
   512     for a:= Low(TAmmoType) to High(TAmmoType) do
   508         newAmmos[a].Count:= InitialCounts[i][a];
   513         newAmmos[a].Count:= InitialCountsLocal[i][a];
   509     FillAmmoStore(StoresList[i], newAmmos);
   514     FillAmmoStore(StoresList[i], newAmmos);
   510     end;
   515     end;
   511 
   516 
   512 for a:= Low(TAmmoType) to High(TAmmoType) do
   517 for a:= Low(TAmmoType) to High(TAmmoType) do
   513     if Ammoz[a].SkipTurns >= 10000 then
   518     if Ammoz[a].SkipTurns >= 10000 then
   543         ammoLoadout:= ammoLoadout + '0';
   548         ammoLoadout:= ammoLoadout + '0';
   544         ammoProbability:= ammoProbability + '0';
   549         ammoProbability:= ammoProbability + '0';
   545         ammoDelay:= ammoDelay + '0';
   550         ammoDelay:= ammoDelay + '0';
   546         ammoReinforcement:= ammoReinforcement + '0'
   551         ammoReinforcement:= ammoReinforcement + '0'
   547         end;
   552         end;
   548     FillChar(InitialCounts, sizeof(InitialCounts), 0)
   553     FillChar(InitialCountsLocal, sizeof(InitialCountsLocal), 0)
   549 end;
   554 end;
   550 
   555 
   551 procedure freeModule;
   556 procedure freeModule;
   552 var i: LongWord;
   557 var i: LongWord;
   553 begin
   558 begin