From 8b4af45f39d8ceea3b08d985cc64c0f16cc89680 Mon Sep 17 00:00:00 2001 From: jokoho482 Date: Mon, 17 May 2021 11:56:11 +0200 Subject: [PATCH 1/2] Rewrite fnc_muting.sqf to include godmode --- addons/sys_core/XEH_PREP.hpp | 1 + addons/sys_core/fnc_muting.sqf | 86 +++++++-------------------- addons/sys_core/fnc_shouldBeMuted.sqf | 28 +++++++++ 3 files changed, 49 insertions(+), 66 deletions(-) create mode 100644 addons/sys_core/fnc_shouldBeMuted.sqf diff --git a/addons/sys_core/XEH_PREP.hpp b/addons/sys_core/XEH_PREP.hpp index 67682c23a..439ae27ff 100644 --- a/addons/sys_core/XEH_PREP.hpp +++ b/addons/sys_core/XEH_PREP.hpp @@ -42,6 +42,7 @@ PREP(replaceGear); PREP(setPluginSetting); PREP(setSpeakingLanguage); PREP(setSpokenLanguages); +PREP(shouldBeMuted); PREP(showBroadCastHint); PREP(speaking); PREP(spectatorOff); diff --git a/addons/sys_core/fnc_muting.sqf b/addons/sys_core/fnc_muting.sqf index a58c8cdc0..48a5bc457 100644 --- a/addons/sys_core/fnc_muting.sqf +++ b/addons/sys_core/fnc_muting.sqf @@ -30,88 +30,42 @@ DFUNC(mutingPFHLoop) = { GVAR(fullListTime) = true; }; private _mutingParams = ""; - private _muting = []; - //private _playerIdList = []; // CHANGE: dynamically get muting distanced based on camera *OR* acre_player position private _dynamicPos = getPos acre_player; if (ACRE_IS_SPECTATOR) then { _dynamicPos = positionCameraToWorld [0, 0, 0]; }; + private _mutedClients = []; + { _x params ["_remoteTs3Id","_remoteUser"]; if (_remoteUser != acre_player) then { - private _muted = 0; - //private _remoteTs3Id = (_remoteUser getVariable QGVAR(ts3id)); - //if (!(isNil "_remoteTs3Id")) then { - if !(_remoteTs3Id in ACRE_SPECTATORS_LIST) then { - private _isRemotePlayerAlive = [_remoteUser] call FUNC(getAlive); - if (_isRemotePlayerAlive == 1) then { - //_playerIdList pushBack _remoteTs3Id; - - // private _radioListRemote = [_remoteUser] call EFUNC(sys_data,getRemoteRadioList); - // private _radioListLocal = [] call EFUNC(sys_data,getPlayerRadioList); - // private _okRadios = [_radioListLocal, _radioListRemote, true] call EFUNC(sys_modes,checkAvailability); - if (GVAR(enableDistanceMuting) && {_remoteUser distance _dynamicPos > 300}) then { - _muting pushBack _remoteUser; - _muted = 1; - if (_remoteUser in GVAR(speakers)) then { - _muted = 0; - }; - }; + private _muted = [_remoteUser, _remoteTs3Id, _dynamicPos] call FUNC(shouldBeMuted); - if (GVAR(fullListTime)) then { - _mutingParams = _mutingParams + format ["%1,%2,", _remoteTs3Id, _muted]; - } else { - if ((_muted == 0 && {_remoteUser in GVAR(muting)}) || {(_muted == 1 && {!(_remoteUser in GVAR(muting))})}) then { - _mutingParams = _mutingParams + format ["%1,%2,", _remoteTs3Id, _muted]; - }; - }; - }; - } else { - _muting pushBack _remoteUser; - }; - //}; - }; - } forEach GVAR(playerList); - - if (!ACRE_IS_SPECTATOR || {GVAR(fullListTime)}) then { - private _newSpectators = ACRE_SPECTATORS_LIST - GVAR(oldSpectators); - if (GVAR(fullListTime)) then { - _newSpectators = ACRE_SPECTATORS_LIST; - }; - if (_newSpectators isNotEqualTo []) then { - { - if (_x != GVAR(ts3id)) then { - _mutingParams = _mutingParams + format ["%1,1,", _x]; + if (GVAR(fullListTime)) then { + _mutingParams = _mutingParams + format ["%1,%2,", _remoteTs3Id, parseNumber _muted]; + if (_muted) then { + _mutedClients pushBack _remoteUser; }; - } forEach _newSpectators; - if (!GVAR(fullListTime)) then { - GVAR(oldSpectators) = +ACRE_SPECTATORS_LIST; + continue; }; - }; - } else { - if ((str ACRE_IS_SPECTATOR) != (str GVAR(lastSpectate))) then { - if (ACRE_IS_SPECTATOR) then { - { - if (_x != GVAR(ts3id)) then { - _mutingParams = _mutingParams + format ["%1,0,", _x]; - }; - } forEach ACRE_SPECTATORS_LIST; + private _isCurrentlyMuted = _remoteUser in GVAR(muting); + if (_isCurrentlyMuted && !_muted) then { + _mutingParams = _mutingParams + format ["%1,0,", _remoteTs3Id]; + GVAR(muting) deleteAt (GVAR(muting) find _remoteUser); + } else { + if (!_isCurrentlyMuted && _muted) then { + _mutingParams = _mutingParams + format ["%1,1,", _remoteTs3Id]; + GVAR(muting) pushBackUnique _remoteUser; + }; }; - GVAR(lastSpectate) = ACRE_IS_SPECTATOR; }; + } forEach GVAR(playerList); + if (GVAR(fullListTime)) then { + GVAR(muting) = _mutedClients; }; - if (ACRE_IS_SPECTATOR && {GVAR(fullListTime)}) then { - { - if (_x != GVAR(ts3id)) then { - _mutingParams = _mutingParams + format ["%1,0,", _x]; - }; - } forEach ACRE_SPECTATORS_LIST; - }; - - GVAR(muting) = _muting; if (GVAR(fullListTime)) then { GVAR(waitFullSend) = diag_tickTime + FULL_SEND_INTERVAL; GVAR(fullListTime) = false; diff --git a/addons/sys_core/fnc_shouldBeMuted.sqf b/addons/sys_core/fnc_shouldBeMuted.sqf new file mode 100644 index 000000000..fcb73543d --- /dev/null +++ b/addons/sys_core/fnc_shouldBeMuted.sqf @@ -0,0 +1,28 @@ +#include "script_component.hpp" +/* + * Author: ACRE2Team + * Check if a remote TS Client Should be muted + * + * Arguments: + * 0: Unit + * 1: Remote TS Id + * 2: Dynamic Position + * + * Return Value: + * Unit Should Be Muted + * + * Example: + * [] call acre_sys_core_fnc_shouldBeMuted + * + * Public: No + */ +params ["_remoteUser", "_remoteTs3Id", "_dynamicPos"]; + +if (_remoteUser in EGVAR(sys_godmode,speakingGods)) exitWith { false }; +if (ACRE_IS_SPECTATOR && {_remoteTs3Id in ACRE_SPECTATORS_LIST}) exitWith { false }; +if (!ACRE_IS_SPECTATOR && {_remoteTs3Id in ACRE_SPECTATORS_LIST}) exitWith { true }; +if !([_remoteUser] call FUNC(getAlive)) exitWith { false }; + +GVAR(enableDistanceMuting) +&& {_remoteUser distance _dynamicPos > 300} +&& {!(_remoteUser in GVAR(speakers))} From 34ea684d56cfb3b80c229b02600b7c307b04b2c8 Mon Sep 17 00:00:00 2001 From: jokoho482 Date: Mon, 17 May 2021 20:26:45 +0200 Subject: [PATCH 2/2] Cleanup unused Variables Use Pabst Idea for ACRE_IS_SPECTATOR optimisation --- addons/sys_core/fnc_muting.sqf | 3 --- addons/sys_core/fnc_shouldBeMuted.sqf | 3 +-- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/addons/sys_core/fnc_muting.sqf b/addons/sys_core/fnc_muting.sqf index 48a5bc457..aa8175f94 100644 --- a/addons/sys_core/fnc_muting.sqf +++ b/addons/sys_core/fnc_muting.sqf @@ -17,9 +17,6 @@ #define FULL_SEND_INTERVAL 5 - -GVAR(oldSpectators) = []; -GVAR(lastSpectate) = false; GVAR(waitFullSend) = diag_tickTime; GVAR(fullListTime) = true; diff --git a/addons/sys_core/fnc_shouldBeMuted.sqf b/addons/sys_core/fnc_shouldBeMuted.sqf index fcb73543d..fcf4365e6 100644 --- a/addons/sys_core/fnc_shouldBeMuted.sqf +++ b/addons/sys_core/fnc_shouldBeMuted.sqf @@ -19,8 +19,7 @@ params ["_remoteUser", "_remoteTs3Id", "_dynamicPos"]; if (_remoteUser in EGVAR(sys_godmode,speakingGods)) exitWith { false }; -if (ACRE_IS_SPECTATOR && {_remoteTs3Id in ACRE_SPECTATORS_LIST}) exitWith { false }; -if (!ACRE_IS_SPECTATOR && {_remoteTs3Id in ACRE_SPECTATORS_LIST}) exitWith { true }; +if (_remoteTs3Id in ACRE_SPECTATORS_LIST) exitWith { !ACRE_IS_SPECTATOR }; if !([_remoteUser] call FUNC(getAlive)) exitWith { false }; GVAR(enableDistanceMuting)