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

Core - Fix Fast Channel Switch of VRC-64 #1357

Merged
merged 3 commits into from
Dec 13, 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
5 changes: 5 additions & 0 deletions addons/api/fnc_getRadioChannel.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@ if !(_radioId isEqualType "") exitWith { -1 };
private _channelNumber = [_radioId, "getCurrentChannel"] call EFUNC(sys_data,dataEvent);

if (isNil "_channelNumber") exitWith { -1 };

private _radioType = [_radioId] call EFUNC(sys_radio,getRadioBaseClassname);

if (_radioType == "ACRE_PRC77") exitWith { _channelNumber };

_channelNumber + 1
2 changes: 1 addition & 1 deletion addons/api/fnc_setRadioChannel.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if !(_radioId isEqualType "") exitWith { false };
if (_channelNumber isEqualType 0) then {
private _eventData = _channelNumber - 1;
if (([_radioId] call FUNC(getBaseRadio)) == "ACRE_PRC77") then {
_eventData = [_eventData, 0]; // ACRE_PRC77 expects an array of [mhzKnob, khzKnob]
_eventData = [_channelNumber, 0] // ACRE_PRC77 expects an array of [mhzKnob, khzKnob]
};
[_radioId, "setCurrentChannel", _eventData] call EFUNC(sys_data,dataEvent);
} else {
Expand Down
9 changes: 9 additions & 0 deletions addons/sys_core/fnc_switchChannelFast.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
private _radioType = [_radioId] call EFUNC(sys_radio,getRadioBaseClassname);
private _typeName = getText (configFile >> "CfgAcreComponents" >> _radioType >> "name");
private _isManpack = getNumber (configFile >> "CfgAcreComponents" >> _radioType >> "isPackRadio");
private _isRackRadio = (vehicle acre_player != acre_player) && {_radioId in (([vehicle acre_player] call EFUNC(api,getVehicleRacks)) apply {[_x] call EFUNC(api,getMountedRackRadio)})} && {[_radioId, acre_player] call EFUNC(sys_rack,isRadioAccessible)};

Check notice on line 26 in addons/sys_core/fnc_switchChannelFast.sqf

View workflow job for this annotation

GitHub Actions / build

Using `vehicle` to check if a unit is in a vehicle is inefficient

inefficient "in vehicle" check

if (_isManpack == 0 || {_isRackRadio}) then {
private _channel = [_radioId] call EFUNC(api,getRadioChannel);
Expand All @@ -37,6 +37,15 @@
case "ACRE_PRC152": {
_channel = (_channel + _dir) min 5;
};
case "ACRE_PRC77": {
_channel = (_channel select 0) + _dir;
if (_channel > 22) then {
_channel = 0;
};
if (_channel < 0) then {
_channel = 22;
};
};
default {
_channel = _channel + _dir;
};
Expand Down
4 changes: 1 addition & 3 deletions addons/sys_prc77/radio/fnc_getCurrentChannel.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,4 @@ TRACE_1("GET CURRENT CHANNEL",_this);

params ["", "", "", "_radioData", ""];

private _return = 0;

_return
HASH_GET(_radioData,"currentChannel")
Loading