Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for #214 calls to TFAR functions in scheduled environment #215

Merged
merged 2 commits into from
Sep 11, 2024
Merged
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
4 changes: 2 additions & 2 deletions addons/screenshotMode/functions/fn_toggleTFAR.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ if (!_tfarEnabled) exitWith {};

if (_newState) then {
TFAR_VolumeHudTransparency = GVAR(tfar);
[] call TFAR_fnc_updateSpeakVolumeUI;
{call TFAR_fnc_updateSpeakVolumeUI} call CBA_fnc_directCall;
} else {
GVAR(tfar) = TFAR_VolumeHudTransparency;
TFAR_VolumeHudTransparency = 1;
[] call TFAR_fnc_updateSpeakVolumeUI;
{call TFAR_fnc_updateSpeakVolumeUI} call CBA_fnc_directCall;
};
97 changes: 51 additions & 46 deletions addons/zeus/XEH_preClientInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -38,77 +38,82 @@ if (isClass (configFile >> "CfgPatches" >> "tfar_core")) then {
[
"TFAR_event_OnSWchannelSet",
{
if !(isNull (getAssignedCuratorLogic ace_player)) exitWith {};
[{
if !(isNull (getAssignedCuratorLogic ace_player)) exitWith {};

params ["_unit", "_radio", "_channel", "_additional"];
params ["_unit", "_radio", "_channel", "_additional"];

private _frequency = [(call TFAR_fnc_activeSwRadio), (_channel +1)] call TFAR_fnc_getChannelFrequency;
if (_additional) then {
if (_channel isEqualTo (_unit getVariable [QGVAR(channelAdditionalSW), -1])) exitWith {
_unit setVariable [QGVAR(channelAdditionalSW), nil, true];
_unit setVariable [QGVAR(freqAdditionalSW), nil, true];
private _frequency = [(call TFAR_fnc_activeSwRadio), (_channel +1)] call TFAR_fnc_getChannelFrequency;
if (_additional) then {
if (_channel isEqualTo (_unit getVariable [QGVAR(channelAdditionalSW), -1])) exitWith {
_unit setVariable [QGVAR(channelAdditionalSW), nil, true];
_unit setVariable [QGVAR(freqAdditionalSW), nil, true];
};
_unit setVariable [QGVAR(channelAdditionalSW), _channel, true];
_unit setVariable [QGVAR(freqAdditionalSW), _frequency, true];
}else{
_unit setVariable [QGVAR(channelSW), _channel, true];
_unit setVariable [QGVAR(freqSW), _frequency, true];
};
_unit setVariable [QGVAR(channelAdditionalSW), _channel, true];
_unit setVariable [QGVAR(freqAdditionalSW), _frequency, true];
}else{
_unit setVariable [QGVAR(channelSW), _channel, true];
_unit setVariable [QGVAR(freqSW), _frequency, true];
};
}, _this] call CBA_fnc_directCall;
b-mayr-1984 marked this conversation as resolved.
Show resolved Hide resolved
}
] call CBA_fnc_addEventHandler;

[
"TFAR_event_OnLRchannelSet",
{
if !(isNull (getAssignedCuratorLogic ace_player)) exitWith {};
[{
if !(isNull (getAssignedCuratorLogic ace_player)) exitWith {};

params ["_unit", "", "", "_channel", "_additional"];
params ["_unit", "", "", "_channel", "_additional"];

// TFAR_fnc_activeLRRadio has to be called in a non-scheduled environment
private _frequency = {[(call TFAR_fnc_activeLRRadio), (_channel + 1)] call TFAR_fnc_getChannelFrequency; } call CBA_fnc_directCall;
if (_additional) then {
private _frequency = [(call TFAR_fnc_activeLRRadio), (_channel + 1)] call TFAR_fnc_getChannelFrequency;
if (_additional) then {

if (_channel isEqualTo (_unit getVariable [QGVAR(freqAdditionalLR), -1])) exitWith {
_unit setVariable [QGVAR(channelAdditionalLR), nil, true];
_unit setVariable [QGVAR(freqAdditionalLR), nil, true];
if (_channel isEqualTo (_unit getVariable [QGVAR(freqAdditionalLR), -1])) exitWith {
_unit setVariable [QGVAR(channelAdditionalLR), nil, true];
_unit setVariable [QGVAR(freqAdditionalLR), nil, true];
};
_unit setVariable [QGVAR(channelAdditionalLR), _channel, true];
_unit setVariable [QGVAR(freqAdditionalLR), _frequency, true];
}else{
_unit setVariable [QGVAR(channelLR), _channel, true];
_unit setVariable [QGVAR(freqLR), _frequency, true];
};
_unit setVariable [QGVAR(channelAdditionalLR), _channel, true];
_unit setVariable [QGVAR(freqAdditionalLR), _frequency, true];
}else{
_unit setVariable [QGVAR(channelLR), _channel, true];
_unit setVariable [QGVAR(freqLR), _frequency, true];
};
}, _this] call CBA_fnc_directCall;
b-mayr-1984 marked this conversation as resolved.
Show resolved Hide resolved
}
] call CBA_fnc_addEventHandler;

[
"TFAR_event_OnFrequencyChanged",
{
if !(isNull (getAssignedCuratorLogic ace_player)) exitWith {};
[{
if !(isNull (getAssignedCuratorLogic ace_player)) exitWith {};

params ["_unit", "_radio", "_channel", "", "_frequency"];
params ["_unit", "_radio", "_channel", "", "_frequency"];

private _backpackLR = call TFAR_fnc_activeLRRadio;
if (_backpackLR isEqualTo _radio) then {
if (_channel isEqualTo (_unit getVariable [QGVAR(channelLR), -1])) then {
_unit setVariable [QGVAR(freqLR), _frequency, true];
}else{
if (_channel isEqualTo (_unit getVariable [QGVAR(channelAdditionalLR), -1])) then {
_unit setVariable [QGVAR(freqAdditionalLR), _frequency, true];
};
};
}else{
private _loadoutRadio = call TFAR_fnc_activeSwRadio;
if (_loadoutRadio isEqualTo _radio) then {
if (_channel isEqualTo (_unit getVariable [QGVAR(channelSW), -1])) then {
_unit setVariable [QGVAR(freqSW), _frequency, true];
private _backpackLR = call TFAR_fnc_activeLRRadio;
if (_backpackLR isEqualTo _radio) then {
if (_channel isEqualTo (_unit getVariable [QGVAR(channelLR), -1])) then {
_unit setVariable [QGVAR(freqLR), _frequency, true];
}else{
if (_channel isEqualTo (_unit getVariable [QGVAR(channelAdditionalSW), -1])) then {
_unit setVariable [QGVAR(freqAdditionalSW), _frequency, true];
if (_channel isEqualTo (_unit getVariable [QGVAR(channelAdditionalLR), -1])) then {
_unit setVariable [QGVAR(freqAdditionalLR), _frequency, true];
};
};
}else{
private _loadoutRadio = call TFAR_fnc_activeSwRadio;
if (_loadoutRadio isEqualTo _radio) then {
if (_channel isEqualTo (_unit getVariable [QGVAR(channelSW), -1])) then {
_unit setVariable [QGVAR(freqSW), _frequency, true];
}else{
if (_channel isEqualTo (_unit getVariable [QGVAR(channelAdditionalSW), -1])) then {
_unit setVariable [QGVAR(freqAdditionalSW), _frequency, true];
};
};
};
};
};
}, _this] call CBA_fnc_directCall;
b-mayr-1984 marked this conversation as resolved.
Show resolved Hide resolved
}
] call CBA_fnc_addEventHandler;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,37 @@ if (isClass (configFile >> "CfgPatches" >> "acre_main")) then {
};

if (isClass (configFile >> "CfgPatches" >> "tfar_core")) then {
private _radioSW = call TFAR_fnc_activeSwRadio;
if (!(isNil "_radioSW") && {!(_radioSW isEqualTo "")} && {(player getVariable [QGVAR(freqSW), -1]) isEqualTo -1}) then {

private _radioChannelSW = _radioSW call TFAR_fnc_getSwChannel;
if (!(isNil "_radioChannelSW") && {!(_radioChannelSW isEqualTo -1)}) then {
player setVariable [QGVAR(channelSW), _radioChannelSW, true];
player setVariable [QGVAR(freqSW), [_radioSW, (_radioChannelSW +1)] call TFAR_fnc_getChannelFrequency, true];
};

private _radioAdditionalChannelSW = _radioSW call TFAR_fnc_getAdditionalSwChannel;
if (!(isNil "_radioAdditionalChannelSW") && {!(_radioAdditionalChannelSW isEqualTo -1)}) then {
player setVariable [QGVAR(channelAdditionalSW), _radioAdditionalChannelSW, true];
player setVariable [QGVAR(freqAdditionalSW), [_radioSW, (_radioAdditionalChannelSW +1)] call TFAR_fnc_getChannelFrequency, true];
{
private _radioSW = call TFAR_fnc_activeSwRadio;
if (!(isNil "_radioSW") && {!(_radioSW isEqualTo "")} && {(player getVariable [QGVAR(freqSW), -1]) isEqualTo -1}) then {

private _radioChannelSW = _radioSW call TFAR_fnc_getSwChannel;
if (!(isNil "_radioChannelSW") && {!(_radioChannelSW isEqualTo -1)}) then {
player setVariable [QGVAR(channelSW), _radioChannelSW, true];
player setVariable [QGVAR(freqSW), [_radioSW, (_radioChannelSW +1)] call TFAR_fnc_getChannelFrequency, true];
};

private _radioAdditionalChannelSW = _radioSW call TFAR_fnc_getAdditionalSwChannel;
if (!(isNil "_radioAdditionalChannelSW") && {!(_radioAdditionalChannelSW isEqualTo -1)}) then {
player setVariable [QGVAR(channelAdditionalSW), _radioAdditionalChannelSW, true];
player setVariable [QGVAR(freqAdditionalSW), [_radioSW, (_radioAdditionalChannelSW +1)] call TFAR_fnc_getChannelFrequency, true];
};
};
};

private _radioLR = call TFAR_fnc_activeLRRadio;
if (!(isNil "_radioLR") && {!(_radioSW isEqualTo "")} && {(player getVariable [QGVAR(freqLR), -1]) isEqualTo -1}) then {
private _radioLR = call TFAR_fnc_activeLRRadio;
if (!(isNil "_radioLR") && {!(_radioSW isEqualTo "")} && {(player getVariable [QGVAR(freqLR), -1]) isEqualTo -1}) then {

private _radioChannelLR = _radioLR call TFAR_fnc_getLrChannel;
if (!(isNil "_radioChannelLR") && {!(_radioChannelLR isEqualTo -1)}) then {
player setVariable [QGVAR(channelLR), _radioChannelLR, true];
player setVariable [QGVAR(freqLR), [_radioLR, (_radioChannelLR +1)] call TFAR_fnc_getChannelFrequency, true];
};
private _radioChannelLR = _radioLR call TFAR_fnc_getLrChannel;
if (!(isNil "_radioChannelLR") && {!(_radioChannelLR isEqualTo -1)}) then {
player setVariable [QGVAR(channelLR), _radioChannelLR, true];
player setVariable [QGVAR(freqLR), [_radioLR, (_radioChannelLR +1)] call TFAR_fnc_getChannelFrequency, true];
};

private _radioAdditionalChannelLR = _radioLR call TFAR_fnc_getAdditionalLrChannel;
if (!(isNil "_radioAdditionalChannelLR") && {!(_radioAdditionalChannelLR isEqualTo -1)}) then {
player setVariable [QGVAR(channelAdditionalLR), _radioAdditionalChannelLR, true];
player setVariable [QGVAR(freqAdditionalLR), [_radioLR, (_radioAdditionalChannelLR +1)] call TFAR_fnc_getChannelFrequency, true];
private _radioAdditionalChannelLR = _radioLR call TFAR_fnc_getAdditionalLrChannel;
if (!(isNil "_radioAdditionalChannelLR") && {!(_radioAdditionalChannelLR isEqualTo -1)}) then {
player setVariable [QGVAR(channelAdditionalLR), _radioAdditionalChannelLR, true];
player setVariable [QGVAR(freqAdditionalLR), [_radioLR, (_radioAdditionalChannelLR +1)] call TFAR_fnc_getChannelFrequency, true];
};
};
};
} call CBA_fnc_directCall;
};
Loading