Calling SetWeapon with amNothing now unselects weapon
authorWuzzy <Wuzzy2@mail.ru>
Wed, 07 Feb 2018 03:50:38 +0100
changeset 12917 a840fd55caa6
parent 12916 20f389ae90b5
child 12918 20e627c1ac20
Calling SetWeapon with amNothing now unselects weapon
ChangeLog.txt
hedgewars/uGearsHedgehog.pas
--- 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:
--- 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