Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions addons/sys_core/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ PREP(replaceGear);
PREP(setPluginSetting);
PREP(setSpeakingLanguage);
PREP(setSpokenLanguages);
PREP(shouldBeMuted);
PREP(showBroadCastHint);
PREP(speaking);
PREP(spectatorOff);
Expand Down
89 changes: 20 additions & 69 deletions addons/sys_core/fnc_muting.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@

#define FULL_SEND_INTERVAL 5


GVAR(oldSpectators) = [];
GVAR(lastSpectate) = false;
GVAR(waitFullSend) = diag_tickTime;
GVAR(fullListTime) = true;

Expand All @@ -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;
Expand Down
27 changes: 27 additions & 0 deletions addons/sys_core/fnc_shouldBeMuted.sqf
Original file line number Diff line number Diff line change
@@ -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))}