Assign ammo counts as well, in case the game flags were changed by the script
authornemo
Sun, 15 Jan 2012 12:40:48 -0500
changeset 6563 30e042398411
parent 6562 e6b35a238d69
child 6568 ad83229a7d98
Assign ammo counts as well, in case the game flags were changed by the script
hedgewars/uScript.pas
--- a/hedgewars/uScript.pas	Sat Jan 14 14:59:19 2012 +0100
+++ b/hedgewars/uScript.pas	Sun Jan 15 12:40:48 2012 -0500
@@ -1881,7 +1881,7 @@
 end;
 
 procedure ScriptApplyAmmoStore;
-var i, j : LongInt;
+var i, j, k : LongInt;
 begin
 SetAmmoLoadout(ScriptAmmoLoadout);
 SetAmmoProbability(ScriptAmmoProbability);
@@ -1890,14 +1890,26 @@
 
 if (GameFlags and gfSharedAmmo) <> 0 then
     for i:= 0 to Pred(ClansCount) do
-        AddAmmoStore
+        begin
+        AddAmmoStore;
+        for j:= 0 to Pred(ClansArray[i]^.TeamsNumber) do
+            for k:= 0 to Pred(ClansArray[i]^.Teams[j]^.HedgehogsNumber) do
+                ClansArray[i]^.Teams[j]^.Hedgehogs[k].AmmoStore:= StoreCnt - 1
+        end
 else if (GameFlags and gfPerHogAmmo) <> 0 then
     for i:= 0 to Pred(TeamsCount) do
         for j:= 0 to Pred(TeamsArray[i]^.HedgehogsNumber) do
-            AddAmmoStore
+            begin
+            AddAmmoStore;
+            TeamsArray[i]^.Hedgehogs[j].AmmoStore:= StoreCnt - 1
+            end
 else 
     for i:= 0 to Pred(TeamsCount) do
-        AddAmmoStore
+        begin
+        AddAmmoStore;
+        for j:= 0 to Pred(TeamsArray[i]^.HedgehogsNumber) do
+            TeamsArray[i]^.Hedgehogs[j].AmmoStore:= StoreCnt - 1
+        end
 end;
 
 procedure initModule;