mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Only sync A3 VON status over network
This commit is contained in:
parent
1488ba2aac
commit
91c8c89e87
@ -20,8 +20,8 @@ if (isServer) then {
|
||||
//If someone disconnects while speaking, reset their variable
|
||||
addMissionEventHandler ["HandleDisconnect", {
|
||||
PARAMS_1(_disconnectedPlayer);
|
||||
if (_disconnectedPlayer getVariable [QGVAR(isSpeaking), false]) then {
|
||||
_disconnectedPlayer setVariable [QGVAR(isSpeaking), false, true];
|
||||
if (_disconnectedPlayer getVariable [QGVAR(isSpeakingInGame), false]) then {
|
||||
_disconnectedPlayer setVariable [QGVAR(isSpeakingInGame), false, true];
|
||||
};
|
||||
}];
|
||||
};
|
||||
@ -31,46 +31,39 @@ if (!hasInterface) exitWith {};
|
||||
["playerChanged", {
|
||||
//When player changes, make sure to reset old unit's variable
|
||||
PARAMS_2(_newUnit,_oldUnit);
|
||||
if (_oldUnit getVariable [QGVAR(isSpeaking), false]) then {
|
||||
_oldUnit setVariable [QGVAR(isSpeaking), false, true];
|
||||
if ((!isNull _oldUnit) && {_oldUnit getVariable [QGVAR(isSpeakingInGame), false]}) then {
|
||||
_oldUnit setVariable [QGVAR(isSpeakingInGame), false, true];
|
||||
};
|
||||
}] call EFUNC(common,addEventHandler);
|
||||
|
||||
//PFEH to watch the internal VON icon
|
||||
//Note: class RscDisplayVoiceChat {idd = 55}; //only present when talking
|
||||
[{
|
||||
_oldSetting = ACE_player getVariable [QGVAR(isSpeakingInGame), false];
|
||||
_newSetting = (!(isNull findDisplay 55));
|
||||
if (!(_oldSetting isEqualTo _newSetting)) then {
|
||||
ACE_player setVariable [QGVAR(isSpeakingInGame), _newSetting, true];
|
||||
};
|
||||
} , 0.1, []] call CBA_fnc_addPerFrameHandler;
|
||||
|
||||
//For performance, chose different code paths at mission start based on installed mods (once, instead of checking each time)
|
||||
_pfEHCode = switch (true) do {
|
||||
|
||||
DFUNC(isSpeaking) = switch (true) do {
|
||||
case (isClass (configFile >> "cfgPatches" >> "acre_api")): {
|
||||
{
|
||||
_oldSetting = ACE_player getVariable [QGVAR(isSpeaking), false];
|
||||
_newSetting = ([ACE_player] call acre_api_fnc_isSpeaking) || ([ACE_player] call acre_api_fnc_isBroadcasting) || {!(isNull findDisplay 55)};
|
||||
if (!(_oldSetting isEqualTo _newSetting)) then {
|
||||
ACE_player setVariable [QGVAR(isSpeaking), _newSetting, true];
|
||||
};
|
||||
PARAMS_1(_unit);
|
||||
(_unit getVariable [QGVAR(isSpeakingInGame), false]) || ([_unit] call acre_api_fnc_isSpeaking) || ([ACE_player] call acre_api_fnc_isBroadcasting)
|
||||
};
|
||||
};
|
||||
case (isClass (configFile >> "cfgPatches" >> "task_force_radio")): {
|
||||
//Note: TFAR has a TFAR_fnc_isSpeaking function, but it has a fairly costly `callExtension`
|
||||
//I think it's much faster to use the internal "tf_isSpeaking" variable
|
||||
//If we don't care about the built-in VON, we could switch this to a pure event driven system
|
||||
{
|
||||
_oldSetting = ACE_player getVariable [QGVAR(isSpeaking), false];
|
||||
_newSetting = (ACE_player getVariable ["tf_isSpeaking", false]) || {!(isNull findDisplay 55)};
|
||||
if (!(_oldSetting isEqualTo _newSetting)) then {
|
||||
ACE_player setVariable [QGVAR(isSpeaking), _newSetting, true];
|
||||
};
|
||||
PARAMS_1(_unit);
|
||||
(_unit getVariable [QGVAR(isSpeakingInGame), false]) || (_unit getVariable ["tf_isSpeaking", false])
|
||||
};
|
||||
};
|
||||
default {
|
||||
//Note: class RscDisplayVoiceChat {idd = 55}; //only present when talking
|
||||
{
|
||||
_oldSetting = ACE_player getVariable [QGVAR(isSpeaking), false];
|
||||
_newSetting = (!(isNull findDisplay 55));
|
||||
if (!(_oldSetting isEqualTo _newSetting)) then {
|
||||
ACE_player setVariable [QGVAR(isSpeaking), _newSetting, true];
|
||||
};
|
||||
PARAMS_1(_unit);
|
||||
(_unit getVariable [QGVAR(isSpeakingInGame), false])
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
//Is 0.05sec precision enough??
|
||||
[_pfEHCode, 0.05, []] call CBA_fnc_addPerFrameHandler;
|
||||
|
Loading…
Reference in New Issue
Block a user