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..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; @@ -30,88 +27,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; - }; - }; - - 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); + private _muted = [_remoteUser, _remoteTs3Id, _dynamicPos] call FUNC(shouldBeMuted); - 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..fcf4365e6 --- /dev/null +++ b/addons/sys_core/fnc_shouldBeMuted.sqf @@ -0,0 +1,27 @@ +#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 (_remoteTs3Id in ACRE_SPECTATORS_LIST) exitWith { !ACRE_IS_SPECTATOR }; +if !([_remoteUser] call FUNC(getAlive)) exitWith { false }; + +GVAR(enableDistanceMuting) +&& {_remoteUser distance _dynamicPos > 300} +&& {!(_remoteUser in GVAR(speakers))}