don't abort changeammo on attacking/attacked in infattack mode, keep scrolling through slot after setweap even if a multishoot was aborted triggering gstattacked, to ensure proper ammo gets set for next turn
authornemo
Sun, 01 Dec 2013 13:22:06 -0500
changeset 9732 a13afa6c5d21
parent 9731 953197ac43d8
child 9733 37f84780eb14
don't abort changeammo on attacking/attacked in infattack mode, keep scrolling through slot after setweap even if a multishoot was aborted triggering gstattacked, to ensure proper ammo gets set for next turn
hedgewars/uGearsHedgehog.pas
--- a/hedgewars/uGearsHedgehog.pas	Sat Nov 30 22:34:39 2013 -0500
+++ b/hedgewars/uGearsHedgehog.pas	Sun Dec 01 13:22:06 2013 -0500
@@ -65,7 +65,7 @@
     HHGear^.Message:= HHGear^.Message and (not gmSlot);
     prevAmmo:= CurAmmoType;
     ammoidx:= 0;
-    if ((HHGear^.State and (gstAttacking or gstAttacked)) <> 0)
+    if (((HHGear^.State and (gstAttacking or gstAttacked)) <> 0) and (GameFlags and gfInfAttack = 0))
     or ((HHGear^.State and gstHHDriven) = 0) then
         exit;
     ChangeAmmo:= true;
@@ -140,6 +140,7 @@
     weap: TAmmoType;
     Hedgehog: PHedgehog;
     s: boolean;
+    prevState, newState: LongWord;
 begin
 s:= false;
 
@@ -155,12 +156,18 @@
 
 HHGear^.Message:= HHGear^.Message and (not gmWeapon);
 
+prevState:= HHGear^.State;
+newState:= prevState;
 with Hedgehog^ do
     while (CurAmmoType <> weap) and (t >= 0) do
         begin
         s:= ChangeAmmo(HHGear);
+        if HHGear^.State <> prevState then // so we can keep gstAttacked out of consideration when looping
+            newState:= HHGear^.State;
+        HHGear^.State:= prevState;
         dec(t)
         end;
+HHGear^.State:= newState;
 
 if s then
     ApplyAmmoChanges(HHGear^.Hedgehog^)