# HG changeset patch # User Wuzzy # Date 1557230171 -7200 # Node ID d4a19bf6687e5b69902188d18cc5bec5d572342a # Parent 5a6da39c5f2ae0727e3b2012e4ddb6fc68bcde88 Fix incorrect handling of slow/precise volume change when it's not your turn diff -r 5a6da39c5f2a -r d4a19bf6687e hedgewars/uCommandHandlers.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 diff -r 5a6da39c5f2a -r d4a19bf6687e hedgewars/uInputHandler.pas --- 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); diff -r 5a6da39c5f2a -r d4a19bf6687e hedgewars/uUtils.pas --- 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