# HG changeset patch
# User Wuzzy <Wuzzy2@mail.ru>
# Date 1517971838 -3600
# Node ID a840fd55caa6a922655c46affe72e30fe2c20b23
# Parent  20f389ae90b5491682a40aa8bbffff3bd0c9050c
Calling SetWeapon with amNothing now unselects weapon

diff -r 20f389ae90b5 -r a840fd55caa6 ChangeLog.txt
--- a/ChangeLog.txt	Wed Feb 07 02:26:31 2018 +0100
+++ b/ChangeLog.txt	Wed Feb 07 03:50:38 2018 +0100
@@ -16,6 +16,7 @@
 
 Lua API:
  + New call: WriteLnToChat(string): Add a line in the chat
+ * Fix call: SetWeapon(amNothing) now unselects weapon
 
 ====================== 0.9.23 ======================
 HIGHLIGHTS:
diff -r 20f389ae90b5 -r a840fd55caa6 hedgewars/uGearsHedgehog.pas
--- a/hedgewars/uGearsHedgehog.pas	Wed Feb 07 02:26:31 2018 +0100
+++ b/hedgewars/uGearsHedgehog.pas	Wed Feb 07 03:50:38 2018 +0100
@@ -141,6 +141,16 @@
 weap:= TAmmoType(HHGear^.MsgParam);
 Hedgehog:= HHGear^.Hedgehog;
 
+HHGear^.Message:= HHGear^.Message and (not gmWeapon);
+
+// Special case: amNothing unselects weapon
+if weap = amNothing then
+    begin
+    HHGear^.Hedgehog^.CurAmmoType:= amNothing;
+    ApplyAmmoChanges(HHGear^.Hedgehog^);
+    exit
+    end;
+
 if Hedgehog^.Team^.Clan^.TurnNumber <= Ammoz[weap].SkipTurns then
     exit; // weapon is not activated yet
 
@@ -148,8 +158,6 @@
 
 t:= cMaxSlotAmmoIndex;
 
-HHGear^.Message:= HHGear^.Message and (not gmWeapon);
-
 prevState:= HHGear^.State;
 newState:= prevState;
 with Hedgehog^ do