Lua: Fix SwitchHog breaking the ammo menu of the new hog
authorWuzzy <almikes@aol.com>
Fri, 28 Apr 2017 02:18:21 +0200
changeset 12371 2b1dd699b371
parent 12365 92b4bab79c26
child 12372 35e76306b016
Lua: Fix SwitchHog breaking the ammo menu of the new hog
ChangeLog.txt
hedgewars/uScript.pas
--- a/ChangeLog.txt	Fri Apr 28 00:21:16 2017 +0200
+++ b/ChangeLog.txt	Fri Apr 28 02:18:21 2017 +0200
@@ -250,6 +250,7 @@
  + Locale library: loc_noop -- Mark string for translation but don't translate it
  + Animate library: AnimInit([startAnimating]) -- New parameter startAnimating: if true, will start game in cinematic mode with most controls disabled. Must play an animation after that
  * Fixed call: HideHog(gear) -- Fix crash when gear is invalid. Returns true on success or false otherwise
+ * Fixed call: SwitchHog(gear) -- Fix new hog being unable to open ammo menu
  * Removed call: SetAmmoStore -- Old undocumented function of questional use, has never been used
 
 0.9.21 -> 0.9.22
--- a/hedgewars/uScript.pas	Fri Apr 28 00:21:16 2017 +0200
+++ b/hedgewars/uScript.pas	Fri Apr 28 02:18:21 2017 +0200
@@ -1638,8 +1638,14 @@
                 end;
 
             SwitchCurrentHedgehog(gear^.Hedgehog);
+            AmmoMenuInvalidated:= true;
             CurrentTeam:= CurrentHedgehog^.Team;
 
+            repeat
+                CurrentTeam^.CurrHedgehog := (CurrentTeam^.CurrHedgehog + 1) mod CurrentTeam^.HedgehogsNumber
+            until
+                CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear = CurrentHedgehog^.Gear;
+
             gear^.State:= gear^.State or gstHHDriven;
             gear^.Active := true;
             gear^.Z := cCurrHHZ;