Fix incorrect handling of slow/precise volume change when it's not your turn
authorWuzzy <Wuzzy2@mail.ru>
Tue, 07 May 2019 13:56:11 +0200
changeset 14895 d4a19bf6687e
parent 14894 5a6da39c5f2a
child 14896 63357ed39886
Fix incorrect handling of slow/precise volume change when it's not your turn
hedgewars/uCommandHandlers.pas
hedgewars/uInputHandler.pas
hedgewars/uUtils.pas
--- a/hedgewars/uCommandHandlers.pas	Tue May 07 13:15:00 2019 +0200
+++ b/hedgewars/uCommandHandlers.pas	Tue May 07 13:56:11 2019 +0200
@@ -33,23 +33,6 @@
 var cTagsMasks : array[0..15] of byte = (7, 0, 0, 0, 0, 4, 5, 6, 15, 8, 8, 8, 8, 12, 13, 14);
     cTagsMasksNoHealth: array[0..15] of byte = (3, 0, 1, 2, 0, 0, 0, 0, 11, 8, 9, 10, 8, 8, 8, 8);
 
-// helper function for volume
-procedure updateVolumeDelta(precise: boolean);
-begin
-if cVolumeUpKey and (not cVolumeDownKey) then
-    if precise then
-        cVolumeDelta:= 1
-    else
-        cVolumeDelta:= 3
-else if cVolumeDownKey and (not cVolumeUpKey) then
-    if precise then
-        cVolumeDelta:= -1
-    else
-        cVolumeDelta:= -3
-else
-    cVolumeDelta:= 0;
-end;
-
 procedure chGenCmd(var s: shortstring);
 begin
 case s[1] of
@@ -294,7 +277,6 @@
 procedure chPrecise_p(var s: shortstring);
 begin
 s:= s; // avoid compiler hint
-updateVolumeDelta(true);
 if CheckNoTeamOrHH then
     exit;
 if not isExternalSource then
@@ -308,7 +290,6 @@
 procedure chPrecise_m(var s: shortstring);
 begin
 s:= s; // avoid compiler hint
-updateVolumeDelta(false);
 if CheckNoTeamOrHH then
     exit;
 if not isExternalSource then
--- a/hedgewars/uInputHandler.pas	Tue May 07 13:15:00 2019 +0200
+++ b/hedgewars/uInputHandler.pas	Tue May 07 13:56:11 2019 +0200
@@ -246,7 +246,10 @@
         if CurrentBinds.binds[CurrentBinds.indices[code]] = 'switch' then
             LocalMessage:= LocalMessage or gmSwitch
         else if CurrentBinds.binds[CurrentBinds.indices[code]] = '+precise' then
+            begin
             LocalMessage:= LocalMessage or gmPrecise;
+            updateVolumeDelta(true);
+            end;
 
         ParseCommand(CurrentBinds.binds[CurrentBinds.indices[code]], Trusted);
         if (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then
@@ -255,7 +258,10 @@
     else if (CurrentBinds.binds[CurrentBinds.indices[code]][1] = '+') then
         begin
         if CurrentBinds.binds[CurrentBinds.indices[code]] = '+precise' then
+            begin
             LocalMessage:= LocalMessage and (not gmPrecise);
+            updateVolumeDelta(false);
+            end;
         s:= CurrentBinds.binds[CurrentBinds.indices[code]];
         s[1]:= '-';
         ParseCommand(s, Trusted);
--- a/hedgewars/uUtils.pas	Tue May 07 13:15:00 2019 +0200
+++ b/hedgewars/uUtils.pas	Tue May 07 13:56:11 2019 +0200
@@ -83,6 +83,8 @@
 
 function CalcWorldWrap(X, radius: LongInt): LongInt;
 
+procedure updateVolumeDelta(precise: boolean);
+
 function read1stLn(filePath: shortstring): shortstring;
 function readValueFromINI(key, filePath: shortstring): shortstring;
 
@@ -698,6 +700,23 @@
     sanitizeCharForLog:= r
 end;
 
+// helper function for volume change controls
+procedure updateVolumeDelta(precise: boolean);
+begin
+if cVolumeUpKey and (not cVolumeDownKey) then
+    if precise then
+        cVolumeDelta:= 1
+    else
+        cVolumeDelta:= 3
+else if cVolumeDownKey and (not cVolumeUpKey) then
+    if precise then
+        cVolumeDelta:= -1
+    else
+        cVolumeDelta:= -3
+else
+    cVolumeDelta:= 0;
+end;
+
 function read1stLn(filePath: shortstring): shortstring;
 var f: pfsFile;
 begin